Proposal: Remove Semigroup and Monoid instances for Data.Map, Data.IntMap, Data.HashMap

Oliver Charles ollie at
Wed Feb 14 09:25:17 UTC 2018

On Wed, Feb 14, 2018 at 8:49 AM, Akio Takano <tkn.akio at> wrote:

> I can think of 3 reasonable definitions for (<>) for lazy maps:
> 1. (<>) = union
> 2. (<>) = unionWith (<>)
> 3. (<>) = Strict.unionWith (<>)
> Of these, (1) is by far the most useful operation in my experience.
> (2) has the advantage that it seems like the most obvious choice, but
> it's not very useful in practice. (3) is slightly more useful than
> (2), but feels less canonical. Also (3) seems inconsistent with how
> fmap is defined.

I think you are very much in the minority here. (1) which we have now is
almost never what I want. (2) is much more likely to be what I need. And of
course, you can recover (1) with (2) by simply mapping First into every

So there doesn't seem to be a clear winner. Perhaps there shouldn't
> have been a Monoid instance for maps in the first place. Given that we
> already have one, however, it seems that the marginal gain of removing
> it doesn't justify the cost of breaking code.

There should be a Monoid instance, and argues that it should be (2).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Libraries mailing list