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/
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to