diff options
Diffstat (limited to 'compiler/GHC/Utils/Monad.hs')
-rw-r--r-- | compiler/GHC/Utils/Monad.hs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/GHC/Utils/Monad.hs b/compiler/GHC/Utils/Monad.hs index 8ba0eefb34..19b0667ceb 100644 --- a/compiler/GHC/Utils/Monad.hs +++ b/compiler/GHC/Utils/Monad.hs @@ -11,6 +11,7 @@ module GHC.Utils.Monad , zipWith3M, zipWith3M_, zipWith4M, zipWithAndUnzipM , mapAndUnzipM, mapAndUnzip3M, mapAndUnzip4M, mapAndUnzip5M , mapAccumLM + , liftFstM, liftSndM , mapSndM , concatMapM , mapMaybeM @@ -164,6 +165,12 @@ mapSndM f xs = go xs go [] = return [] go ((a,b):xs) = do { c <- f b; rs <- go xs; return ((a,c):rs) } +liftFstM :: Monad m => (a -> b) -> m (a, r) -> m (b, r) +liftFstM f thing = do { (a,r) <- thing; return (f a, r) } + +liftSndM :: Monad m => (a -> b) -> m (r, a) -> m (r, b) +liftSndM f thing = do { (r,a) <- thing; return (r, f a) } + -- | Monadic version of concatMap concatMapM :: Monad m => (a -> m [b]) -> [a] -> m [b] concatMapM f xs = liftM concat (mapM f xs) |