Best practices
This page contains a few best practices for writing Haskell code.
Code style
In CS 132, we will be collectively building one piece of software, so we want to use a consistent style.
Loosely, we will follow this style guide. The guide contains a lot of rules and suggestions, but you don’t need to memorize them all! Instead, our editor will enforce the rules for us. In our projects, there will be a file called .stylish-haskell.yaml, which contains rules for formatting Haskell code. The projects are configured to format the code when the file is saved.
If you are using an editor other than VSCode, be sure to configure it to use these rules. Usually, configuring the editor requires finding a way to run the stylish-haskell program when you save a file. However, if your editor is hooked up to HLS, the language server can also be configured to run stylish-haskell.
Code documentation
We will use Haddock notation to document our code. In addition to being a consistent format for documentation, using Haddock allows us to auto-generate documentation for our code.
Hoogle
Hoogle is a search engine for Haskell code, built on top of Haddock documentation. It allows us to search for utilities by name or by type.
We can also generate a local version of Hoogle, which includes our source code! See this article for more information.