[Haskell-cafe] PrefixMap: code review request

Brian Hulley brianh at metamilk.com
Mon Feb 27 18:35:40 EST 2006

David F. Place wrote:
> On Feb 27, 2006, at 5:54 PM, Brian Hulley wrote:
>> there is a parse error (using ghc) at the line beginning with
>> result'. This binding doesn't line up with anything. Also the
>> second 'where' is dangerously close to the column started by the
>> 'f' after the first 'where' (may not be noticeable in this email
>> due to whatever font it is being displayed in but it's only
>> indented by one space) which makes it a bit tricky to read.
> Whoops, that's noise in the transmission.  In my original file and my
> original email, it is indented correctly.  As for other indentation
> issues, I always use whatever emacs suggests.  Is that not a good
> strategy?

I always think it's a bit like income tax! Over the centuries the rules have 
got more and more complicated and instead of simplifying everything, 
computers have allowed all this mess to survive which ultimately makes life 
difficult for us poor humans because no-one knows any more what's going on 
(except a computer which has its own agenda for humanity...)

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. A like-minded person has then created an 
emacs mode which supports this. It is probably also possible to create an 
emacs macro to safely rename identifiers by first parsing the code, doing 
the renaming in the AST, then pretty-printing the code back into the file.

However if you voluntarily use only a restricted subset of all possible 
layouts, you end up with non-brittle code that can be edited in any editor 
(eg someone else's editor who doesn't understand emacs:-) ) and where safely 
renaming identifiers is just a simple text-based search-and-replace 

Of course having said all this, many people have strong personal views about 
different ways of laying out code, whether to use tabs or not, etc etc.

I was just using your example as an excuse for some "consciousness-raising" 
about safe vs brittle layouts, but of course at the end of the day everyone 
has to decide for themselves. For example you might find that the aesthetics 
or readability of a 'brittle' layout, or the ease of editing using the 
particular emacs mode, outweighs the disadvantages of its being brittle.

As Dr Flox said on Star Trek Enterprise to T'Pol "Infinite diversity in 
infinite combinations" !!! :-)

Best regards, Brian. 

More information about the Haskell-Cafe mailing list