Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- cont :: ((a -> r) -> r) -> Cont r a
- mapCont :: (r -> r) -> Cont r a -> Cont r a
- mapContT :: forall {k} m (r :: k) a. (m r -> m r) -> ContT r m a -> ContT r m a
- runCont :: Cont r a -> (a -> r) -> r
- withCont :: ((b -> r) -> a -> r) -> Cont r a -> Cont r b
- withContT :: forall {k} b m (r :: k) a. ((b -> m r) -> a -> m r) -> ContT r m a -> ContT r m b
- type Cont r = ContT r Identity
- newtype ContT (r :: k) (m :: k -> Type) a = ContT {
- runContT :: (a -> m r) -> m r
- shiftT :: Monad m => ((a -> m r) -> ContT r m r) -> ContT r m a
- shift :: ((a -> r) -> Cont r r) -> Cont r a
- resetT :: forall (m :: Type -> Type) r r'. Monad m => ContT r m r -> ContT r' m r
- reset :: Cont r r -> Cont r' r
- liftLocal :: Monad m => m r' -> ((r' -> r') -> m r -> m r) -> (r' -> r') -> ContT r m a -> ContT r m a
- evalContT :: Monad m => ContT r m r -> m r
- evalCont :: Cont r r -> r
- updateContT :: (m r -> m r) -> ContT r m ()
- stateToReaderContT :: Monad m => StateT s m a -> ContT r (ReaderT s m) a
- hoistContT :: (m1 r1 -> m2 r2) -> (m2 r2 -> m1 r1) -> ContT r1 m1 a -> ContT r2 m2 a
Documentation
cont :: ((a -> r) -> r) -> Cont r a #
Construct a continuation-passing computation from a function.
(The inverse of runCont
)
:: Cont r a | continuation computation ( |
-> (a -> r) | the final continuation, which produces
the final result (often |
-> r |
The result of running a CPS computation with a given final continuation.
(The inverse of cont
)
type Cont r = ContT r Identity #
Continuation monad.
Cont r a
is a CPS ("continuation-passing style") computation that produces an
intermediate result of type a
within a CPS computation whose final result type
is r
.
The return
function simply creates a continuation which passes the value on.
The >>=
operator adds the bound function into the continuation chain.
newtype ContT (r :: k) (m :: k -> Type) a #
The continuation monad transformer.
Can be used to add continuation handling to any type constructor:
the Monad
instance and most of the operations do not require m
to be a monad.
ContT
is not a functor on the category of monads, and many operations
cannot be lifted through it.
Instances
TransConstraint MonadFail (ContT s) Source # | |
Defined in Control.Monad.Ology.Specific.ContT | |
TransConstraint MonadIO (ContT s) Source # | |
Defined in Control.Monad.Ology.Specific.ContT | |
TransConstraint Applicative (ContT s) Source # | |
Defined in Control.Monad.Ology.Specific.ContT hasTransConstraint :: forall (m :: Type -> Type). Applicative m => Dict (Applicative (ContT s m)) Source # | |
TransConstraint Functor (ContT s) Source # | |
Defined in Control.Monad.Ology.Specific.ContT | |
TransConstraint Monad (ContT s) Source # | |
Defined in Control.Monad.Ology.Specific.ContT | |
MonadTransCoerce (ContT r) Source # | |
MonadTrans (ContT r) | |
Defined in Control.Monad.Trans.Cont | |
MonadFail m => MonadFail (ContT r m) | |
Defined in Control.Monad.Trans.Cont | |
MonadIO m => MonadIO (ContT r m) | |
Defined in Control.Monad.Trans.Cont | |
Applicative (ContT r m) | |
Functor (ContT r m) | |
Monad (ContT r m) | |
Invariant (ContT r m) | from the |
Defined in Data.Functor.Invariant | |
MonadCont (ContT r m) Source # | |
liftLocal :: Monad m => m r' -> ((r' -> r') -> m r -> m r) -> (r' -> r') -> ContT r m a -> ContT r m a #
updateContT :: (m r -> m r) -> ContT r m () Source #
hoistContT :: (m1 r1 -> m2 r2) -> (m2 r2 -> m1 r1) -> ContT r1 m1 a -> ContT r2 m2 a Source #
Orphan instances
TransConstraint MonadFail (ContT s) Source # | |
TransConstraint MonadIO (ContT s) Source # | |
TransConstraint Applicative (ContT s) Source # | |
hasTransConstraint :: forall (m :: Type -> Type). Applicative m => Dict (Applicative (ContT s m)) Source # | |
TransConstraint Functor (ContT s) Source # | |
TransConstraint Monad (ContT s) Source # | |
MonadTransCoerce (ContT r) Source # | |
MonadCont (ContT r m) Source # | |