Commit 3a1efe1a authored by Richard Lupton's avatar Richard Lupton Committed by Marge Bot

Re-export foldlM and foldrM from Data.Foldable in MonadUtils (#16969)

parent ac7c738b
...@@ -32,7 +32,7 @@ import Control.Applicative ...@@ -32,7 +32,7 @@ import Control.Applicative
import Control.Monad import Control.Monad
import Control.Monad.Fix import Control.Monad.Fix
import Control.Monad.IO.Class import Control.Monad.IO.Class
import Data.Foldable (sequenceA_, foldr) import Data.Foldable (sequenceA_, foldlM, foldrM)
import Data.List (unzip4, unzip5, zipWith4) 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) ...@@ -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 :: Monad m => m Bool -> m Bool -> m Bool
orM m1 m2 = m1 >>= \x -> if x then return True else m2 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 -- | Monadic version of foldl that discards its result
foldlM_ :: (Monad m, Foldable t) => (a -> b -> m a) -> a -> t b -> m () foldlM_ :: (Monad m, Foldable t) => (a -> b -> m a) -> a -> t b -> m ()
foldlM_ = foldM_ 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 -- | Monadic version of fmap specialised for Maybe
maybeMapM :: Monad m => (a -> m b) -> (Maybe a -> m (Maybe b)) maybeMapM :: Monad m => (a -> m b) -> (Maybe a -> m (Maybe b))
maybeMapM _ Nothing = return Nothing maybeMapM _ Nothing = return Nothing
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment