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

Joachim Breitner mail at
Wed Feb 14 15:03:09 UTC 2018


Am Mittwoch, den 14.02.2018, 09:47 -0500 schrieb Mario Blažević:
>         I understand it's hard to grep, but can you guess how many of those 
> 40-80 uses of (<>) with the union meaning actually depend on the 
> left-biased semantics? I've looked at my code, and it turns out that 
> wherever this operation appears, the two maps are guaranteed to have 
> distinct keys.

does this indicate the need for

    disjointUnion :: IntMap a -> IntMap a -> IntMap a

that throws an error when the maps are not disjoint? (run-time error
only, because we are not doing theorem proving here…)

One can get the effect with

    unionWith (error "not disjoint)

of course (and I have done so), but having `disjointUnion` in the API
might remind people that they have to think about which variant they


Joachim Breitner
  mail at
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <>

More information about the Libraries mailing list