less than serious - PreludeExts

Wolfgang Jeltsch wolfgang at jeltsch.net
Mon Jan 19 13:17:38 EST 2004


Am Sonntag, 18. Januar 2004 22:26 schrieb Tom Pledger:
> [...]

> 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.)

Since you can use return instead of box, defining box doesn't make much sense 
to me.  When I created a list module with types for non-empty and infinite 
lists, I asked myself the question if adding a box-like function for 
non-empty lists would make sense.  I dropped this idea since return does the 
work and having too many functions makes a library's interface unnecessarily 
complex.

> Regards,
> Tom

Wolfgang



More information about the Libraries mailing list