| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Synopsis | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Documentation | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class Monad m => MonadPlus m where | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| join :: Monad m => m (m a) -> m a | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| The join function is the conventional monad join operator. It is used to remove one level of monadic structure, projecting its bound argument into the outer level. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| guard :: MonadPlus m => Bool -> m () | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| guard b is return () if b is True, and mzero if b is False. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| when :: Monad m => Bool -> m () -> m () | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Conditional execution of monadic expressions. For example, when debug (putStr "Debugging\n") will output the string Debugging\n if the Boolean value debug is True, and otherwise do nothing. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| unless :: Monad m => Bool -> m () -> m () | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| The reverse of when. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ap :: Monad m => m (a -> b) -> m a -> m b | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
In many situations, the liftM operations can be replaced by uses of ap, which promotes function application. return f `ap` x1 `ap` ... `ap` xn is equivalent to liftMn f x1 x2 ... xn | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| msum :: MonadPlus m => [m a] -> m a | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This generalizes the list-based concat function. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| filterM :: Monad m => (a -> m Bool) -> [a] -> m [a] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This generalizes the list-based filter function. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mapAndUnzipM :: Monad m => (a -> m (b, c)) -> [a] -> m ([b], [c]) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| The mapAndUnzipM function maps its first argument over a list, returning the result as a pair of lists. This function is mainly used with complicated data structures or a state-transforming monad. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| zipWithM :: Monad m => (a -> b -> m c) -> [a] -> [b] -> m [c] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| The zipWithM function generalizes zipWith to arbitrary monads. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| zipWithM_ :: Monad m => (a -> b -> m c) -> [a] -> [b] -> m () | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| zipWithM_ is the extension of zipWithM which ignores the final result. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| foldM :: Monad m => (a -> b -> m a) -> a -> [b] -> m a | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The foldM function is analogous to foldl, except that its result is encapsulated in a monad. Note that foldM works from left-to-right over the list arguments. This could be an issue where '(>>)' and the `folded function' are not commutative. foldM f a1 [x1, x2, ..., xm ] == do
a2 <- f a1 x1
a3 <- f a2 x2
...
f am xm
If right-to-left evaluation is required, the input list should be reversed. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| liftM :: Monad m => (a1 -> r) -> m a1 -> m r | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Promote a function to a monad. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| liftM2 :: Monad m => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Promote a function to a monad, scanning the monadic arguments from left to right. For example, liftM2 (+) [0,1] [0,2] = [0,2,1,3]
liftM2 (+) (Just 1) Nothing = Nothing
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| liftM3 :: Monad m => (a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Promote a function to a monad, scanning the monadic arguments from left to right (cf. liftM2). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| liftM4 :: Monad m => (a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Promote a function to a monad, scanning the monadic arguments from left to right (cf. liftM2). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| liftM5 :: Monad m => (a1 -> a2 -> a3 -> a4 -> a5 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m a5 -> m r | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Promote a function to a monad, scanning the monadic arguments from left to right (cf. liftM2). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class Monad m where | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class Functor f where | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mapM :: Monad m => (a -> m b) -> [a] -> m [b] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mapM f is equivalent to sequence . map f. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mapM_ :: Monad m => (a -> m b) -> [a] -> m () | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mapM_ f is equivalent to sequence_ . map f. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sequence :: Monad m => [m a] -> m [a] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Evaluate each action in the sequence from left to right, and collect the results. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sequence_ :: Monad m => [m a] -> m () | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Evaluate each action in the sequence from left to right, and ignore the results. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (=<<) :: Monad m => (a -> m b) -> m a -> m b | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Same as >>=, but with the arguments interchanged. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Produced by Haddock version 2.7.2 |