map and fmap

Jon Fairbairn jon.fairbairn at cl.cam.ac.uk
Fri Aug 18 13:04:01 EDT 2006


On 2006-08-18 at 17:30+0200 "John Hughes" wrote:
> > From: Jon Fairbairn <jon.fairbairn at cl.cam.ac.uk>
> >
> > A reasonable choice (forestalling the objection that using
> > List.map, listMap or mapList would be too distracting for
> > students) would be
> >
> >   lmap:: (t -> t') -> [t] -> [t']
> >   map:: Functor f => (t -> t') -> f t -> f t'
> >
> 
> I'd prefer mapList to lmap, to be honest--at least the
> connection between the name and the type is clear. But
> remember, this would at a stroke make Haskell'
> incompatible with all existing Haskell textbooks.

so publishers should love it! ;-)

> Even if publishers brought out new editions, even if we
> told students to buy them, there are many, many second
> hand books in circulation, and it would be years before
> one could rely on students having Haskell' books. All that
> time, students would write map instead of mapList because
> that's what the book says, and get stuck with
> incomprehensible error messages. Is it really worth an
> incompatible change in the library functions used by all
> beginners, just to rename fmap to map?  It seems to me
> that the gain from a change is very small, and the cost
> considerable.

It depends over how long a time you amortise the cost.  I've
heard that when people complained about the problems of
having tab significant in makefiles, no correction was made
because there were about a dozen users.  We're farther on
than that, but still at a stage where the population of
users is not that large, and the users are flexible. So I
think we should be reasonably bold about these things. To
reinforce what Aaron said, if a programme works now, it'll
still work if map suddenly means fmap.

 Jón


-- 
Jón Fairbairn                              Jon.Fairbairn at cl.cam.ac.uk




More information about the Haskell-prime mailing list