561e29f0469aba2ac373a01c57cf32df0832c758
[haskell-report.git] / report / lib-hdrs / Monad.hs
1 module Monad (
2 MonadPlus(mzero, mplus),
3 join, guard, when, unless, ap,
4 msum,
5 filterM, mapAndUnzipM, zipWithM, zipWithM_, foldM,
6 liftM, liftM2, liftM3, liftM4, liftM5,
7
8 -- ...and what the Prelude exports
9 Monad((>>=), (>>), return, fail),
10 Functor(fmap),
11 mapM, mapM_, sequence, sequence_, (=<<),
12 ) where
13
14 class Monad m => MonadPlus m where
15 mzero :: m a
16 mplus :: m a -> m a -> m a
17
18 join :: Monad m => m (m a) -> m a
19 guard :: MonadPlus m => Bool -> m ()
20 when :: Monad m => Bool -> m () -> m ()
21 unless :: Monad m => Bool -> m () -> m ()
22 ap :: Monad m => m (a -> b) -> m a -> m b
23
24 mapAndUnzipM :: Monad m => (a -> m (b,c)) -> [a] -> m ([b], [c])
25 zipWithM :: Monad m => (a -> b -> m c) -> [a] -> [b] -> m [c]
26 zipWithM_ :: Monad m => (a -> b -> m c) -> [a] -> [b] -> m ()
27 foldM :: Monad m => (a -> b -> m a) -> a -> [b] -> m a
28 filterM :: Monad m => (a -> m Bool) -> [a] -> m [a]
29
30 msum :: MonadPlus m => [m a] -> m a
31
32 liftM :: Monad m => (a -> b) -> (m a -> m b)
33 liftM2 :: Monad m => (a -> b -> c) -> (m a -> m b -> m c)
34 liftM3 :: Monad m => (a -> b -> c -> d) ->
35 (m a -> m b -> m c -> m d)
36 liftM4 :: Monad m => (a -> b -> c -> d -> e) ->
37 (m a -> m b -> m c -> m d -> m e)
38 liftM5 :: Monad m => (a -> b -> c -> d -> e -> f) ->
39 (m a -> m b -> m c -> m d -> m e -> m f)
40