[Haskell-cafe] Re: PrefixMap: code review request

Ben Rudiak-Gould Benjamin.Rudiak-Gould at cl.cam.ac.uk
Tue Feb 28 08:14:16 EST 2006


Brian Hulley wrote:
> Whoever thought up the original Haskell layout rule assumed that people 
> would be happy using a single fixed width font, tabs set to 8 spaces, 
> and didn't care about the brittleness of the code (in the face of 
> identifier renamings) it allowed one to write.

Are you complaining that Haskell permits you to write code with these 
problems, or that it requires you to? The latter is not true. Instead of

     keyword clause1
             clause2

you can always write

     keyword
       clause1
       clause2

or

     keyword { clause1
             ; clause2
             }

Both styles are insensitive to tab width and renaming of identifiers. The 
off-side rule only comes into play when you don't include an explicit {, so 
you can suppress it entirely if you prefer.

If you have a different layout rule in mind I'd be interested in hearing it, 
but I think Haskell's is quite good overall. Lisp has similar indentation 
problems despite the lack of a layout rule, since people commonly write

     (foo (...)
          (...))

Renaming foo can't confuse the compiler, but I've never had a Haskell layout 
error change the meaning of my program. At worst it causes the program to be 
rejected.

I do edit my source code in a fixed-width font, but it's a very pretty font 
(Bitstream Vera Sans Mono). It's a small price to pay for the convenience of 
being able to use 2D layout, even in languages where it's not significant, 
and in comments.

-- Ben



More information about the Haskell-Cafe mailing list