Haskell indentation
Hal Daume
t-hald@microsoft.com
Wed, 27 Aug 2003 08:07:29 -0700
Just my 2 cents...
> The first is that I always put the where for local function=20
> definitions
> on a new line, e.g.
> foo x =3D x + a + b
> where a =3D 1 + x
> b =3D 2 * x
> I find this a lot clearer and prettier than,
> foo x =3D x + a + b where
> a =3D 1 + x
> b =3D 2 * x
I used to do it your style, but have switched to:
> foo x =3D x + a + b
> where=20
> a =3D 1 + x
> b =3D 2 * x
because it makes cut&paste easier. instance/class declarations for me
also don't obey this.
> data AST
> =3D Const Int
> | Var String
> | Lam String AST
> | App AST AST
> | Let String AST AST
> | Add AST AST
same here. or for records, I like:
> data Rec =3D
> Rec {
> foo :: Int,
> bar,
> bluff :: String
> }
> Another difficult case that I haven't solidified a style for is large
> type signatures.
I tend to do something like:
> myfoo :: (Context1, Context2, Context3) =3D>
> type1 -> -- maybe a description of type1
> type2 ->
> type3 ->
> result type
it takes a lot more vertical space, but you also have easy
haddockability and it makes it a lot easier to remember what all those
parameters are...
- hal