Good Haskell Style
isaacdupree at charter.net
Wed Aug 1 19:50:53 EDT 2007
Ian Lynagh wrote:
> * Don't leave trailing white space in your code
> * Don't use tabs
> * Aim to keep lines under 80 characters
> * Use the CamelCase variable naming convention
Agreed. And newline at end of file.
And prefer to indent an even number (normally an even number of spaces,
but, an odd number when using birdtrack-literate-haskell '> foo = ...').
I am often quite arbitrary about anything more strictured than this,
and prefer to lay it out depending on what seems most clear in the
surrounding code (which, admittedly, usually assumes a monospace font).
> * Don't use explicit braces and semicolons
Sometimes I use explicit semicolons, and even sometimes braces to make
the bracketing more clear, when there are a lot of small cases, for
example. But usually layout is better.
A separate rule which I do try to stick to is,
* don't depend on the width of non-space characters for layout
: " \(let\|where\|do\|of\)[ ] such that the layout following them
extends onto another line "; however this is a nuisance to check
manually, (is more complicated when tabs are allowed), and GHC doesn't
have a warning flag for it.
More information about the Libraries