, sequence -- :: (Monad m) => [m a] -> m [a]
, sequence_ -- :: (Monad m) => [m a] -> m ()
, (=<<) -- :: (Monad m) => (a -> m b) -> m a -> m b
+ , (>=>) -- :: (Monad m) => (a -> m b) -> (b -> m c) -> (a -> m c)
+ , (<=<) -- :: (Monad m) => (b -> m c) -> (a -> m b) -> (a -> m c)
+ , forever -- :: (Monad m) => m a -> m b
-- ** Generalisations of list functions
-- > mzero >>= f = mzero
-- > v >> mzero = mzero
--
- -- (but the instance for 'System.IO.IO' defined in "Control.Monad.Error"
- -- does not satisfy the second one).
+ -- (but the instance for 'System.IO.IO' defined in Control.Monad.Error
+ -- in the mtl package does not satisfy the second one).
mzero :: m a
-- | an associative operation
mplus :: m a -> m a -> m a
{-# INLINE msum #-}
msum = foldr mplus mzero
+infixr 1 <=<, >=>
+
+-- | Left-to-right Kleisli composition of monads.
+(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> (a -> m c)
+f >=> g = \x -> f x >>= g
+
+-- | Right-to-left Kleisli composition of monads. '(>=>)', with the arguments flipped
+(<=<) :: Monad m => (b -> m c) -> (a -> m b) -> (a -> m c)
+(<=<) = flip (>=>)
+
+-- | @'forever' act@ repeats the action infinitely.
+forever :: (Monad m) => m a -> m b
+forever a = a >> forever a
+
-- -----------------------------------------------------------------------------
-- Other monad functions
ap :: (Monad m) => m (a -> b) -> m a -> m b
ap = liftM2 id
+
{- $naming
The functions in this library use the following naming conventions: