| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Control.Monad.Ology.Specific.ContT
Contents
Synopsis
- shift :: ((a -> r) -> Cont r r) -> Cont r a
- reset :: Cont r r -> Cont r' r
- runCont :: Cont r a -> (a -> r) -> r
- newtype ContT (r :: k) (m :: k -> Type) a = ContT {
- runContT :: (a -> m r) -> m r
- type Cont r = ContT r Identity
- cont :: ((a -> r) -> r) -> Cont r a
- evalCont :: Cont r r -> r
- mapCont :: (r -> r) -> Cont r a -> Cont r a
- withCont :: ((b -> r) -> a -> r) -> Cont r a -> Cont r b
- evalContT :: Monad m => ContT r m r -> m r
- mapContT :: forall {k} m (r :: k) a. (m r -> m r) -> ContT r m a -> ContT r m a
- withContT :: forall {k} b m (r :: k) a. ((b -> m r) -> a -> m r) -> ContT r m a -> ContT r m b
- resetT :: forall (m :: Type -> Type) r r'. Monad m => ContT r m r -> ContT r' m r
- shiftT :: Monad m => ((a -> m r) -> ContT r m r) -> ContT r m a
- liftLocal :: Monad m => m r' -> ((r' -> r') -> m r -> m r) -> (r' -> r') -> ContT r m a -> ContT r m a
- updateContT :: forall {k} m (r :: k). (m r -> m r) -> ContT r m ()
- stateToReaderContT :: forall (m :: Type -> Type) s a r. Monad m => StateT s m a -> ContT r (ReaderT s m) a
- hoistContT :: forall {k1} {k2} m1 (r1 :: k1) m2 (r2 :: k2) a. (m1 r1 -> m2 r2) -> (m2 r2 -> m1 r1) -> ContT r1 m1 a -> ContT r2 m2 a
Documentation
Arguments
| :: 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)
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
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.
cont :: ((a -> r) -> r) -> Cont r a #
Construct a continuation-passing computation from a function.
(The inverse of runCont)
liftLocal :: Monad m => m r' -> ((r' -> r') -> m r -> m r) -> (r' -> r') -> ContT r m a -> ContT r m a #
updateContT :: forall {k} m (r :: k). (m r -> m r) -> ContT r m () Source #
stateToReaderContT :: forall (m :: Type -> Type) s a r. Monad m => StateT s m a -> ContT r (ReaderT s m) a Source #
hoistContT :: forall {k1} {k2} m1 (r1 :: k1) m2 (r2 :: k2) a. (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 # | |
Methods 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 # | |