-- ** Naming conventions
-- $naming
- -- ** Basic functions from the "Prelude"
+ -- ** Basic @Monad@ functions
, mapM -- :: (Monad m) => (a -> m b) -> [a] -> m [b]
, mapM_ -- :: (Monad m) => (a -> m b) -> [a] -> m ()
, (>=>) -- :: (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
+ , void
-- ** Generalisations of list functions
-- > mzero >>= f = mzero
-- > v >> mzero = mzero
--
- -- (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
(>=>) :: 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
+-- | Right-to-left Kleisli composition of monads. @('>=>')@, with the arguments flipped
(<=<) :: Monad m => (b -> m c) -> (a -> m b) -> (a -> m c)
(<=<) = flip (>=>)
forever :: (Monad m) => m a -> m b
forever a = a >> forever a
+-- | @'void' value@ discards or ignores the result of evaluation, such as the return value of an 'IO' action.
+void :: Functor f => f a -> f ()
+void = fmap (const ())
+
-- -----------------------------------------------------------------------------
-- Other monad functions
{- | 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
+the list arguments. This could be an issue where @('>>')@ and the `folded
function' are not commutative.
-> foldM f a1 [x1, x2, ..., xm ]
+> foldM f a1 [x1, x2, ..., xm]
==