We have style guides (and even automatic formatting tools), hlint
, and the Haddock standard for comments. These together ensure that Haskell is uniformly good-looking on the level of syntax. We also have a bunch of warnings (some of which are off by default) that catch many blunders, such as incomplete patterns.
However, there are also high level best practices that one really ought to follow in order to take the best advantage of Haskell. Some examples:
- If you need to acquire a resource and then release it, you should do it with a bracket. (Why?)
- If you are catching all exceptions, you should re-throw asynchronous ones. (Why?)
- Whenever you are mapping, folding or unfolding, you should do it with higher order functions. (Why?)
- Whenever theoretically possible, a type should have exactly the right set of values, so that code is correct by construction. (I think this is the first source?)
- You should parse, not validate. (I recall the opposite is called Ā«boolean blindnessĀ»?)
- You should know which functions in the standard libraries are safe and easy to understand, and which are dangerous and confusing. (There is some work to codify this.)
These best practices are disparately mentioned here and there. If I forget some of them (and I know I do), there is no way for me to refresh my memory. Further, it is hard to explain to a programmer with a Ā«traditionalĀ» background how Haskell is different ā it is very much possible to write stringly typed imperative code in Haskell!
How much better life would be if all known best practices were codified!
If there is a reference for this, please link me to it. Otherwise, please throw your best practices in comments and I shall compose that reference from your suggestions and put it on the Internet.