dp wiz avatar dp wiz committed b0c39e6

collapse mapMmap

Comments (0)

Files changed (1)


 ) where
 import Control.Applicative (pure, (<$>))
+import Control.Monad (liftM, liftM2)
 import qualified Data.Text as T
 import qualified Data.Text.Lazy as TL
 import qualified Data.Text.Encoding as TE
 {-# INLINE mapMset #-}
 mapMmap :: (Ord a2, Monad m) => (a1 -> m a2) -> (b1 -> m b2) -> M.Map a1 b1 -> m (M.Map a2 b2)
-mapMmap kf vf m = do
-    let pairsIn = M.assocs m
-    pairsOut <- mapM fs pairsIn
-    return $! M.fromList pairsOut
-    where
-        fs (k, v) = do
-            newK <- kf k
-            newV <- vf v
-            return (newK, newV)
+mapMmap kf vf = liftM M.fromList . mapM (\(k, v) -> liftM2 (,) (kf k) (vf v)) . M.assocs
 {-# INLINE mapMmap #-}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.