Good Haskell Style

Thomas Schilling nominolo at googlemail.com
Wed Aug 1 17:49:54 EDT 2007


Oh, and while we're at arbitrary style rules, I have one more (with a  
reason though, to do so).  I find this way of indenting "where"  
really annoying:

   fun :: Yawn -> Moo a -> Meep a
   fun y x = do
       unMoo x
       blah
       return it
       where
       blah = foo 42
       it = blax &&& meee . y

it should rather be

   fun :: Yawn -> Moo a -> Meep a
   fun y x = do
       unMoo x
       blah
       return it
     where
       blah = foo 42
       it = blax &&& meee . y

Even if the "where" is syntax-highlighted, it is still very hard to  
parse visually.



In a completely unrelated issue, I think this is a very useful way to  
indent code:

   foo x y z = case x of
     Blab a b c   -> ...
     Blib d e f g -> ...
     _            -> ...

It helps avoiding parentheses and reduces line length (especially for  
longer function names).  Compare this with:

   foo (Blab a b c) y z   = ...
   foo (Blib d e f g) y z = ...
   foo x y z = ...

/ Thomas


More information about the Libraries mailing list