[Haskell-cafe] Formatting function types

Lauri Alanko la at iki.fi
Thu Dec 30 14:33:55 CET 2010


On Thu, Dec 30, 2010 at 07:04:11AM -0600, Larry Evans wrote:
> On 12/29/10 22:40, Daryoush Mehrtash wrote:
> > Why do people  put  ";" in do {}, or "," in data fields,  at the 
> > beginning of the line? 
> > -- 
> It reflects the parse tree better by putting the
> combining operators (e.g. ';' and ',') at the left
> and their operands (or combined subtrees) indented
> to the right.

I will take this opportunity to mention again a related pet peeve of
mine that I originally griped about ages ago:

http://www.mail-archive.com/haskell-cafe@haskell.org/msg02231.html

Even nowadays, Haddock deliberately generates the following layout for
long function types:

openTempFile
    :: FilePath
    -> String
    -> IO (FilePath, Handle)    

The layout draws special attention to the first argument type, whereas
the other argument types are indistinguishable from the return
type. The following is much clearer:

openTempFile :: 
    FilePath ->
    String ->
    IO (FilePath, Handle)    

(Possibly with the arrows aligned.)

I can't understand how the "arrows first" convention still lingers so
strongly when it is (to me) so obviously wrong and misleading. Please,
folks, at least pay a thought to what different indentation and line
continuation styles express before adopting one.


Lauri



More information about the Haskell-Cafe mailing list