[Haskell-cafe] dear traversable

Ben midfield at gmail.com
Fri Jul 30 23:13:43 EDT 2010

dear traversable geniuses --

i am looking for "better" implementations of

unzipMap :: M.Map a (b, c) -> (M.Map a b, M.Map a c)
unzipMap m = (M.map fst m, M.map snd m)

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

the first is obviously inefficient as it traverses the map twice.  the
second just seems like it is some kind of fmap.

any ideas?


More information about the Haskell-Cafe mailing list