I always preferred (I think going back to my lisp days)

    foo x y
          z

indenting subsequent arguments to the same level as the first, but I have not 
convinced haskell-mode to do that for me. (The general rule here being that 
similar things should be at the same indent, which will always result in 
subexpressions being further indented, but is somewhat more specific.)

The case I never quite know what to do with is a series of expressions 
connected with operators, e.g.

    foo
    <|> bar
    <|> baz

Leaving operators at the beginning of lines (rather than trailing the previous 
line) seems preferable, but does one (where the layout rules apply) align the 
operator or the function? (the alternative being, if your mail client does not 
make a mess of it with a variable-width font)

        foo
    <|> bar
    <|> baz

~IRS
________________________________________
From: haskell-cafe-boun...@haskell.org [haskell-cafe-boun...@haskell.org] on 
behalf of Richard Cobbe [co...@ccs.neu.edu]
Sent: Monday, July 01, 2013 8:00 AM
To: haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] question about indentation conventions

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

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to