11module Control.Monad
22 ( class Monad
33 , liftM1
4- , ap
54 , whenM
65 , unlessM
76 , module Data.Functor
@@ -12,7 +11,7 @@ module Control.Monad
1211
1312import Control.Applicative (class Applicative , liftA1 , pure , unless , when )
1413import Control.Apply (class Apply , apply , (*>), (<*), (<*>))
15- import Control.Bind (class Bind , bind , ifM , join , (<=<), (=<<), (>=>), (>>=))
14+ import Control.Bind (class Bind , bind , ap , ifM , join , (<=<), (=<<), (>=>), (>>=))
1615
1716import Data.Functor (class Functor , map , void , ($>), (<#>), (<$), (<$>))
1817import Data.Unit (Unit )
@@ -27,7 +26,6 @@ import Data.Unit (Unit)
2726-- |
2827-- | - Left Identity: `pure x >>= f = f x`
2928-- | - Right Identity: `x >>= pure = x`
30- -- | - Applicative Superclass: `apply = ap`
3129class (Applicative m , Bind m ) <= Monad m
3230
3331instance monadFn :: Monad ((-> ) r )
@@ -50,23 +48,6 @@ liftM1 f a = do
5048 a' <- a
5149 pure (f a')
5250
53- -- | `ap` provides a default implementation of `(<*>)` for any
54- -- | [`Monad`](#monad), without using `(<*>)` as provided by the
55- -- | [`Apply`](#apply)-[`Monad`](#monad) superclass relationship.
56- -- |
57- -- | `ap` can therefore be used to write [`Apply`](#apply) instances as
58- -- | follows:
59- -- |
60- -- | ```purescript
61- -- | instance applyF :: Apply F where
62- -- | apply = ap
63- -- | ```
64- ap :: forall m a b . Monad m => m (a -> b ) -> m a -> m b
65- ap f a = do
66- f' <- f
67- a' <- a
68- pure (f' a')
69-
7051-- | Perform a monadic action when a condition is true, where the conditional
7152-- | value is also in a monadic context.
7253whenM :: forall m . Monad m => m Boolean -> m Unit -> m Unit
0 commit comments