Proposal: more general unionWith for Data.Map

Johan Tibell johan.tibell at
Tue Jan 24 22:58:19 CET 2012

On Tue, Jan 24, 2012 at 1:25 PM, Milan Straka <fox at> wrote:
> I think that with intersectionWithKey, we are still holding to the
> mathematical idea. Imagine I have a Map Hash List. When performing
> intersection of two such maps, it can happen that for one hash there are
> different values in the maps and so in the intersection the has is not
> present.
> Generally if the Map k a is representing a set using both k and a,
> the intersection on the same key can still be empty.

But Map doesn't model a set using both k and a, if it did this would hold:

  length (insert 1 'a' (insert 1 'b') empty) == 2

i.e. we would have a multimap.

-- Johan

More information about the Libraries mailing list