Module Control.Monad.Extra

Author
Michael Hanus, Fredrik Wieczerkowski
Version
September 2026

Some additional operations on monads.

Exported Functions


concatMapM :: Monad b => (a -> b [c]) -> [a] -> b [c]  Deterministic 

Same as concatMap, but for a monadic function.


mapAccumM :: Monad c => (a -> b -> c (a, d)) -> a -> [b] -> c (a, [d])  Deterministic 

Same as mapM but with an additional accumulator threaded through.


unlessM :: Monad a => a Bool -> a () -> a ()  Deterministic 

Monadic version of unless where the condition is defined by a monadic operation.


whenM :: Monad a => a Bool -> a () -> a ()  Deterministic 

Monadic version of when where the condition is defined by a monadic operation.


ifM :: Monad a => a Bool -> a b -> a b -> a b  Deterministic 

Monadic version of if where the condition is defined by a monadic operation.