less than serious - PreludeExts

Tom Pledger Tom.Pledger at peace.com
Mon Jan 19 10:26:02 EST 2004


Shae Matijs Erisson writes:
 | In the true spirit of wikiwiki comes PreludeExts, all the tiny
 | useful bits of code you think should be in the Prelude, but aren't.
 | 
 | http://www.haskell.org/hawiki/PreludeExts

The very first function in there

    box x = [x]

reminds me of a style issue which doesn't get much attention.  The
issue is vocabulary.  If I'm reading someone else's code (or my own
old code), this

    map box xs

may well sidetrack me onto finding the definition of box, whereas this

    map (\x -> [x]) xs

is more self contained, and not much longer.  (I don't mean any
offence to the author and users of 'box'; it's a matter of personal
preference, how big a function neds to be before it deserves a name.)

Regards,
Tom



More information about the Libraries mailing list