Make Prelude's map = fmap

Alec alec at deviant-logic.net
Mon Jun 24 17:12:02 CEST 2013


On Sun, Jun 23, 2013 at 2:20 PM, Nikita Volkov <nikita.y.volkov at gmail.com>wrote:
> That's exactly what I am doing now and the very existence of a dozen of
> "prelude" projects on hackage suggests that I'm hardly alone in that.

As the author of one of those projects wherein I rather joyously
pollute the namespace, I still elected not to do the "map = fmap"
thing.  I had two main reasons:

1. fmap (or (<$>)) isn't a terribly onerous thing to type.  (I did end
up exporting (<>), because typing "mappend" is clearly an intolerable
burden.)

2. Code that works with fmap in my prelude will work with fmap without
my prelude.  Changing map means a type error (rather than, at worst,
an unbound identifier) should someone elect not to use my prelude one
day.

While generalizing map doesn't break old code, it makes it somewhat
more annoying to backport new code.

-A



More information about the Libraries mailing list