[Haskell-cafe] question about indentation conventions

Richard Cobbe cobbe at ccs.neu.edu
Mon Jul 1 14:00:14 CEST 2013


On Mon, Jul 01, 2013 at 05:18:39PM +1200, Richard A. O'Keefe wrote:
>
> It looked pretty explicit to me:
>
>       The golden rule of indentation
>       ...
>       you will do fairly well if you just remember a single rule:
>       Code which is part of some expression should be indented
>       further in than the beginning of that expression (even if
>       the expression is not the leftmost element of the line).
>
> This means for example that
>       f (g x
>           y
>           z)
> is OK but
>       f (g x
>       y z)
> is not.
>

Sure.  So my first question boils down to which of the two alternatives
below does the community prefer?  (To be clear about the intended
semantics: this is the application of the function f to the arguments x, y,
and z.)

    f x
    y
    z

or

    f x
     y
     z

Both are correct, in most contexts.

And then there's the second question: if the second alternative is
preferable, is there a way to get haskell-mode to do it automatically?  As
it is, it refuses to indent y any farther to the right than in the first
alternative.  I can space it in by hand, and then haskell-mode puts z under
y, but that's annoying, and it gets in the way of reindenting large regions
of code automatically.

Richard



More information about the Haskell-Cafe mailing list