Code style guide?

Duncan Coutts duncan.coutts at
Fri Mar 22 19:35:09 CET 2013

On Tue, 2013-03-19 at 07:29 -0700, Johan Tibell wrote:
> On Tue, Mar 19, 2013 at 6:35 AM, Duncan Coutts <duncan.coutts at
> > wrote:
> > Go for it!
> >
> > You'll also notice that the code uses different styles in different
> > places (because of different authors). We've not gone through and tidied
> > stuff up because we're lazy and because there never seems to be a good
> > time to do it (it causes conflicts with patches people are working on).
> >
> If you need to write a style guide, why not use
> as a starting point. It's widely used in the Haskell community nowadays
> (e.g. it's a common recommendation on IRC) and it's based on the coding
> style of Duncan, Bryan, and Don for the most part.

BTW, the main thing in that guide that I disagree with is the 4-space
indentation. I always use 2, but at the top level there's a slight
special case:

foo :: a -> b
foo x =
    bar x
    bar y = ...

We have to indent the body of the function here by 4 because the where
has to be indented by 2, and the body has to be more than that, this is
partly for clarity but also partly because of this problem:

foo x = case x of
  This ->
  That ->
    bar y = ...

IIRC, historically in H98 this attached the where to the top level
function foo, but these days with the modified layout rule, the where
gets attached to the last branch of the case.


More information about the cabal-devel mailing list