Q:

Non commutative intersection over Maps

How can I define function, that for each key of first map lookup a value of second map, apply some function to these 2 values and generate third map?
∷ (α → Maybe β → γ) → Map k α → Map k β → Map k γ
I played a little bit with some combinations of unionWith, differenceWith and intersectionWith, but stuck on mixing them with lookup.

A:

Is
foo :: (α → Maybe β → γ) → Map k α → Map k β → Map k γ
foo comb ma mb = Map.mapWithKey (\k a -> comb a (Map.lookup k mb)) ma

what you want?

