Control.Monad.Cont
- Package
- purescript-transformers
- Repository
- purescript/purescript-transformers
This module defines the Cont
inuation monad.
Re-exports from Control.Monad.Cont.Class
#MonadCont Source
class (Monad m) <= MonadCont m where
The MonadCont
type class represents those monads which support the
callCC
, or call-with-current-continuation operation.
This action makes the current continuation available to the caller.
For example:
-- setTimeout :: Number -> Effect Unit -> Effect Unit
delay :: Number -> ContT Unit Effect Unit
delay n = callCC \cont ->
lift $ setTimeout n (runContT (cont unit) (\_ -> pure unit))
An implementation is provided for ContT
, and for other monad transformers
defined in this library.
Members
callCC :: forall a. ((forall b. a -> m b) -> m a) -> m a
Re-exports from Control.Monad.Cont.Trans
#ContT Source
newtype ContT r m a
Constructors
ContT ((a -> m r) -> m r)
Instances
Newtype (ContT r m a) _
(Monad m) => MonadCont (ContT r m)
(Functor m) => Functor (ContT r m)
(Apply m) => Apply (ContT r m)
(Applicative m) => Applicative (ContT r m)
(Bind m) => Bind (ContT r m)
(Monad m) => Monad (ContT r m)
MonadTrans (ContT r)
(MonadEffect m) => MonadEffect (ContT r m)
(MonadAsk r1 m) => MonadAsk r1 (ContT r m)
(MonadReader r1 m) => MonadReader r1 (ContT r m)
(MonadState s m) => MonadState s (ContT r m)
(Apply m, Semigroup a) => Semigroup (ContT r m a)
(Applicative m, Monoid a) => Monoid (ContT r m a)
#MonadTrans Source
class MonadTrans t where
The MonadTrans
type class represents monad transformers.
A monad transformer is a type constructor of kind (* -> *) -> * -> *
, which
takes a Monad
as its first argument, and returns another Monad
.
This allows us to add additional effects to an existing monad. By iterating this process, we create monad transformer stacks, which contain all of the effects required for a particular computation.
The laws state that lift
is a Monad
morphism.
Laws:
lift (pure a) = pure a
lift (do { x <- m ; y }) = do { x <- lift m ; lift y }
Members
- Modules
- Control.
Comonad. Env - Control.
Comonad. Env. Class - Control.
Comonad. Env. Trans - Control.
Comonad. Store - Control.
Comonad. Store. Class - Control.
Comonad. Store. Trans - Control.
Comonad. Traced - Control.
Comonad. Traced. Class - Control.
Comonad. Traced. Trans - Control.
Comonad. Trans. Class - Control.
Monad. Cont - Control.
Monad. Cont. Class - Control.
Monad. Cont. Trans - Control.
Monad. Error. Class - Control.
Monad. Except - Control.
Monad. Except. Trans - Control.
Monad. Identity. Trans - Control.
Monad. List. Trans - Control.
Monad. Maybe. Trans - Control.
Monad. RWS - Control.
Monad. RWS. Trans - Control.
Monad. Reader - Control.
Monad. Reader. Class - Control.
Monad. Reader. Trans - Control.
Monad. State - Control.
Monad. State. Class - Control.
Monad. State. Trans - Control.
Monad. Trans. Class - Control.
Monad. Writer - Control.
Monad. Writer. Class - Control.
Monad. Writer. Trans