Names for small functions: just say no... Re: Data.List.join

Ketil Malde ketil+haskell at ii.uib.no
Tue Oct 24 03:06:12 EDT 2006


Jon Fairbairn <jon.fairbairn at cl.cam.ac.uk> writes:

> If we don't give it a name, learning to read “concat
> . intersperse something” (which is more common than the
> formulation I gave above) means learning intersperse, concat
> and compose -- all of which are invaluable Haskell. But if
> we call it whateverify, there will still be programmes
> around that use concat with intersperse [...]

I agree.  I've always been slightly annoyed at the presence of
'concatMap' since its replacement is so trivial.  Another reason for a
special function could be efficiency.  You could possibly have the
case that intersperse (or map) construct new strings that only get
copied and discarded by the subsequent concat.  (A sufficiently smart
compiler will probably be able to optimize this away, though)

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants



More information about the Libraries mailing list