[Haskell-cafe] dear traversable

John Meacham john at repetae.net
Fri Jul 30 23:21:30 EDT 2010


On Fri, Jul 30, 2010 at 08:13:43PM -0700, Ben wrote:
> unliftMap :: (Ord a) => M.Map a (b -> c) -> M.Map a b -> M.Map a c
> unliftMap mf ma = M.mapWithKey (\k v -> mf M.! k $ v) ma

I always thought a useful map primitive would be

unionWithJoin 
   :: (a -> b -> c)  -- combine values that appear in both maps
   -> (b -> c)       -- value appears in second map but not the first
   -> (a -> c)       -- value appears in first map but not second
   -> Map k a -> Map k b -> Map k c

along with the 'WithKey' and 'Maybe' variants.


        John

-- 
John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/


More information about the Haskell-Cafe mailing list