Safe Haskell | Safe-Inferred |
---|

Extra functions for Control.Exception. These functions provide looping, list operations and booleans. If you need a wider selection of monad loops and list generalisations, see http://hackage.haskell.org/package/monad-loops

- module Control.Monad
- whenJust :: Applicative m => Maybe a -> (a -> m ()) -> m ()
- unit :: m () -> m ()
- partitionM :: Monad m => (a -> m Bool) -> [a] -> m ([a], [a])
- concatMapM :: Monad m => (a -> m [b]) -> [a] -> m [b]
- mapMaybeM :: Monad m => (a -> m (Maybe b)) -> [a] -> m [b]
- loopM :: Monad m => (a -> m (Either a b)) -> a -> m b
- whileM :: Monad m => m Bool -> m ()
- whenM :: Monad m => m Bool -> m () -> m ()
- unlessM :: Monad m => m Bool -> m () -> m ()
- ifM :: Monad m => m Bool -> m a -> m a -> m a
- notM :: Functor m => m Bool -> m Bool
- (||^) :: Monad m => m Bool -> m Bool -> m Bool
- (&&^) :: Monad m => m Bool -> m Bool -> m Bool
- orM :: Monad m => [m Bool] -> m Bool
- andM :: Monad m => [m Bool] -> m Bool
- anyM :: Monad m => (a -> m Bool) -> [a] -> m Bool
- allM :: Monad m => (a -> m Bool) -> [a] -> m Bool
- findM :: Monad m => (a -> m Bool) -> [a] -> m (Maybe a)
- firstJustM :: Monad m => (a -> m (Maybe b)) -> [a] -> m (Maybe b)

# Documentation

module Control.Monad

whenJust :: Applicative m => Maybe a -> (a -> m ()) -> m ()Source

The identity function which requires the inner argument to be '()'. Useful for functions with overloaded return times.

\(x :: Maybe ()) -> unit x == x

partitionM :: Monad m => (a -> m Bool) -> [a] -> m ([a], [a])Source

A version of `partition`

that works with a monadic predicate.

partitionM (Just . even) [1,2,3] == Just ([2], [1,3]) partitionM (const Nothing) [1,2,3] == Nothing

concatMapM :: Monad m => (a -> m [b]) -> [a] -> m [b]Source

A version of `concatMap`

that works with a monadic predicate.

mapMaybeM :: Monad m => (a -> m (Maybe b)) -> [a] -> m [b]Source

A version of `mapMaybe`

that works with a monadic predicate.

firstJustM :: Monad m => (a -> m (Maybe b)) -> [a] -> m (Maybe b)Source