Added a mapMapWithKeyM function to Utils, and cleaned up some of the whitespace
This commit is contained in:
parent
e3bf321f33
commit
e843ce5022
|
@ -303,7 +303,14 @@ data DataBox = forall t. Data t => DataBox t
|
||||||
|
|
||||||
-- A version of mapM that acts on the values in maps.
|
-- A version of mapM that acts on the values in maps.
|
||||||
mapMapM :: (Ord a, Monad m) => (b -> m c) -> Map.Map a b -> m (Map.Map a c)
|
mapMapM :: (Ord a, Monad m) => (b -> m c) -> Map.Map a b -> m (Map.Map a c)
|
||||||
mapMapM f m = liftM Map.fromAscList $ mapM f' $ Map.toAscList m
|
mapMapM f m = mapMapWithKeyM (const f) m
|
||||||
|
|
||||||
|
-- A version of mapM that acts on the values in maps.
|
||||||
|
mapMapWithKeyM :: (Ord a, Monad m) => (a -> b -> m c) -> Map.Map a b -> m (Map.Map a c)
|
||||||
|
mapMapWithKeyM f m = liftM Map.fromAscList $ mapM f' $ Map.toAscList m
|
||||||
where
|
where
|
||||||
f' (x,y) = do y' <- f y
|
f' (x,y) = do y' <- f x y
|
||||||
return (x, y')
|
return (x, y')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user