[Haskell-cafe] question about indentation conventions

Richard Cobbe cobbe at ccs.neu.edu
Mon Jul 1 01:53:08 CEST 2013

I hope I'm not starting a holy war with this, but I'm curious about an
aspect of coding style that's been bugging me for a while, and I'm not
finding much discussion of this question on the web or in the mailing list

Two questions:

1) Are there wide-spread conventions in the Haskell community for how to
indent an application expression that's split across multiple lines?  For
how to indent an expression that uses infix operators?  Or does everyone
pretty much do their own thing?

2) If there is such a convention, how do I make Emacs's haskell-mode do it?

By default, in most cases Emacs's haskell-mode with
turn-on-haskell-indentation does

    function firstArgument
    (second argument)

Personally, I'd prefer some indentation on the 2nd and 3rd lines to
indicate that they're continuing an expression begun on a previous line.

I can use parens around the entire application to force haskell-mode to
indent subsequent lines (and of course this is necessary in some contexts,
like a 'do' expression), but haskell-mode only indents that by a single

    do (function firstArgument
        (second argument)

I'd find a larger indent---even just 2 spaces---to be more readable.

My inclination to indent the second and following lines of a multi-line
application expression is informed by my long experience in Scheme, Racket,
and Lisp, whose S-expressions lend themselves to fairly straightforward
(and automatable!) indentation conventions.  If the Haskell community does
things differently, though, I'm happy to adapt.

This is the sort of thing that one picks up from the community, as in other
languages.  I don't, however, have a whole lot of contact with that
community outside this list -- thus the post, despite the dangers inherent
in discussing subjective stuff like this that people often feel strongly



More information about the Haskell-Cafe mailing list