Proposal: more general unionWith for Data.Map
schlepptop at henning-thielemann.de
Tue Jan 24 20:32:40 CET 2012
Milan Straka schrieb:
> If others agree, it is indeed simple to generalize type of
> unionWith[Key] from
> unionWithKey :: Ord k => (k -> a -> a -> a) -> Map k a -> Map k a -> Map k a
> unionWithKey :: Ord k => (k -> a -> a -> Maybe a) -> Map k a -> Map k a -> Map k a
> These functions are used quite frequently in my opinion, so it will
> probably result in quite a lot of code breaks (unionWith (++) has to be
> changed to unionWith (\a b -> Just (a ++ b))).
Just for consistency with other "With" functions, the result of the
merger function should be 'a' not 'Maybe a'. Maybe 'unionUpdateWithKey'
or so would show the similarity to 'update'.
More information about the Libraries