Hi Richard, This page helped me when starting out: http://en.wikibooks.org/wiki/Haskell/Indentation On 2013-06-30 4:55 PM, "Richard Cobbe" <co...@ccs.neu.edu> wrote:
> 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 > archives. > > 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) > thirdArgument > > 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 > space: > > do (function firstArgument > (second argument) > thirdArgument) > nextAction > > 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 > about. > > Thanks, > > 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