Good Haskell Style

Benjamin Franksen benjamin.franksen at
Fri Aug 3 13:32:40 EDT 2007

Jon Fairbairn wrote:
> Benjamin Franksen <benjamin.franksen at> writes:
>> Jon Fairbairn wrote:
>> > David Roundy <droundy at> writes:
>> >>  I've certainly never heard of a scenario in which
>> >> trailing white space is beneficial.
>> > 
>> > Neither have I, but since it's invisible, asking that it not
>> > be there without providing automatic mechanical assistance
>> > is to add a tedious burden.
>> sed -e 's/[ \t]+$//'
> Not the whole story, surely; 

No, of course not.

> you must want me to do 

I don't want you to do anything at all. I merely wanted to illustrate that
getting rid of trailing whitespace is easily automated. Well, let's say
half-automated: you still need to push the button.

> something like create sort-it:
> #!/bin/bash 
> find /home/jf -name \*.hs -o -name \*.lhs | xargs -IX sed -i.bak -e 's/[
\t]+$//' X
> and put it in a my crontab to run once a day? Otherwise it's
> not automatic. 

No crontab entry needed here (wouldn't help, by the way, since you probably
want to record on the same day you wrote something). Also not necessary to
recurse over whole home directory. It needs to be done only right before
darcs-record-ing changes and only for the standard libraries. As has been
noted by someone else, darcs even helps you by highlighting trailing
whitespace in hunks, in case you forgot to run your script over the source

I agree that a darcs prehook (if they existed) would be an even nicer

> Only, strangely enough, what you wrote 
> doesn't work (s/-e/-r/).

Sorry, I didn't test the code. Forgot to add the usual disclaimer... ;-)

(Always bugs me that sed and grep have these half-regexes as default.)


More information about the Libraries mailing list