summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Lupton <richard.lupton@gmail.com>2019-08-11 20:05:58 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-08-19 02:12:00 -0400
commit3a1efe1aff0c21f1d6d4150a3b05c32d79be2398 (patch)
tree4817f6ee613775ff1c37dc7d084ecb407613e517
parentac7c738b19d626a827b688b6bac28c9beb28541d (diff)
downloadhaskell-3a1efe1aff0c21f1d6d4150a3b05c32d79be2398.tar.gz
Re-export foldlM and foldrM from Data.Foldable in MonadUtils (#16969)
-rw-r--r--compiler/utils/MonadUtils.hs10
1 files changed, 1 insertions, 9 deletions
diff --git a/compiler/utils/MonadUtils.hs b/compiler/utils/MonadUtils.hs
index 936ae62751..72669b9362 100644
--- a/compiler/utils/MonadUtils.hs
+++ b/compiler/utils/MonadUtils.hs
@@ -32,7 +32,7 @@ import Control.Applicative
import Control.Monad
import Control.Monad.Fix
import Control.Monad.IO.Class
-import Data.Foldable (sequenceA_, foldr)
+import Data.Foldable (sequenceA_, foldlM, foldrM)
import Data.List (unzip4, unzip5, zipWith4)
-------------------------------------------------------------------------------
@@ -190,18 +190,10 @@ allM f (b:bs) = (f b) >>= (\bv -> if bv then allM f bs else return False)
orM :: Monad m => m Bool -> m Bool -> m Bool
orM m1 m2 = m1 >>= \x -> if x then return True else m2
--- | Monadic version of foldl
-foldlM :: (Monad m, Foldable t) => (a -> b -> m a) -> a -> t b -> m a
-foldlM = foldM
-
-- | Monadic version of foldl that discards its result
foldlM_ :: (Monad m, Foldable t) => (a -> b -> m a) -> a -> t b -> m ()
foldlM_ = foldM_
--- | Monadic version of foldr
-foldrM :: (Monad m, Foldable t) => (b -> a -> m a) -> a -> t b -> m a
-foldrM k z x = foldr (\x r -> r >>= k x) (pure z) x
-
-- | Monadic version of fmap specialised for Maybe
maybeMapM :: Monad m => (a -> m b) -> (Maybe a -> m (Maybe b))
maybeMapM _ Nothing = return Nothing