monadology-0.3: The best ideas in monad-related classes and types.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Monad.Ology.Specific.ContT

Synopsis

Documentation

cont :: ((a -> r) -> r) -> Cont r a #

Construct a continuation-passing computation from a function. (The inverse of runCont)

mapCont :: (r -> r) -> Cont r a -> Cont r a #

Apply a function to transform the result of a continuation-passing computation.

mapContT :: forall {k} m (r :: k) a. (m r -> m r) -> ContT r m a -> ContT r m a #

Apply a function to transform the result of a continuation-passing computation. This has a more restricted type than the map operations for other monad transformers, because ContT does not define a functor in the category of monads.

runCont #

Arguments

:: Cont r a

continuation computation (Cont).

-> (a -> r)

the final continuation, which produces the final result (often id).

-> r 

The result of running a CPS computation with a given final continuation. (The inverse of cont)

withCont :: ((b -> r) -> a -> r) -> Cont r a -> Cont r b #

Apply a function to transform the continuation passed to a CPS computation.

withContT :: forall {k} b m (r :: k) a. ((b -> m r) -> a -> m r) -> ContT r m a -> ContT r m b #

Apply a function to transform the continuation passed to a CPS computation.

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.

Constructors

ContT 

Fields

Instances

Instances details
TransConstraint MonadFail (ContT s) Source # 
Instance details

Defined in Control.Monad.Ology.Specific.ContT

Methods

hasTransConstraint :: forall (m :: Type -> Type). MonadFail m => Dict (MonadFail (ContT s m)) Source #

TransConstraint MonadIO (ContT s) Source # 
Instance details

Defined in Control.Monad.Ology.Specific.ContT

Methods

hasTransConstraint :: forall (m :: Type -> Type). MonadIO m => Dict (MonadIO (ContT s m)) Source #

TransConstraint Applicative (ContT s) Source # 
Instance details

Defined in Control.Monad.Ology.Specific.ContT

Methods

hasTransConstraint :: forall (m :: Type -> Type). Applicative m => Dict (Applicative (ContT s m)) Source #

TransConstraint Functor (ContT s) Source # 
Instance details

Defined in Control.Monad.Ology.Specific.ContT

Methods

hasTransConstraint :: forall (m :: Type -> Type). Functor m => Dict (Functor (ContT s m)) Source #

TransConstraint Monad (ContT s) Source # 
Instance details

Defined in Control.Monad.Ology.Specific.ContT

Methods

hasTransConstraint :: forall (m :: Type -> Type). Monad m => Dict (Monad (ContT s m)) Source #

MonadTransCoerce (ContT r) Source # 
Instance details

Defined in Control.Monad.Ology.Specific.ContT

Methods

transCoerce :: forall (m1 :: Type -> Type) (m2 :: Type -> Type). Coercible m1 m2 => Dict (Coercible (ContT r m1) (ContT r m2)) Source #

MonadTrans (ContT r) 
Instance details

Defined in Control.Monad.Trans.Cont

Methods

lift :: Monad m => m a -> ContT r m a #

MonadFail m => MonadFail (ContT r m) 
Instance details

Defined in Control.Monad.Trans.Cont

Methods

fail :: String -> ContT r m a #

MonadIO m => MonadIO (ContT r m) 
Instance details

Defined in Control.Monad.Trans.Cont

Methods

liftIO :: IO a -> ContT r m a #

Applicative (ContT r m) 
Instance details

Defined in Control.Monad.Trans.Cont

Methods

pure :: a -> ContT r m a #

(<*>) :: ContT r m (a -> b) -> ContT r m a -> ContT r m b #

liftA2 :: (a -> b -> c) -> ContT r m a -> ContT r m b -> ContT r m c #

(*>) :: ContT r m a -> ContT r m b -> ContT r m b #

(<*) :: ContT r m a -> ContT r m b -> ContT r m a #

Functor (ContT r m) 
Instance details

Defined in Control.Monad.Trans.Cont

Methods

fmap :: (a -> b) -> ContT r m a -> ContT r m b #

(<$) :: a -> ContT r m b -> ContT r m a #

Monad (ContT r m) 
Instance details

Defined in Control.Monad.Trans.Cont

Methods

(>>=) :: ContT r m a -> (a -> ContT r m b) -> ContT r m b #

(>>) :: ContT r m a -> ContT r m b -> ContT r m b #

return :: a -> ContT r m a #

Invariant (ContT r m)

from the transformers package

Instance details

Defined in Data.Functor.Invariant

Methods

invmap :: (a -> b) -> (b -> a) -> ContT r m a -> ContT r m b #

MonadCont (ContT r m) Source # 
Instance details

Defined in Control.Monad.Ology.Specific.ContT

Methods

callCC :: ((a -> ContT r m b) -> ContT r m a) -> ContT r m a Source #

shiftT :: Monad m => ((a -> m r) -> ContT r m r) -> ContT r m a #

shiftT f captures the continuation up to the nearest enclosing resetT and passes it to f:

shift :: ((a -> r) -> Cont r r) -> Cont r a #

shift f captures the continuation up to the nearest enclosing reset and passes it to f:

resetT :: forall (m :: Type -> Type) r r'. Monad m => ContT r m r -> ContT r' m r #

resetT m delimits the continuation of any shiftT inside m.

reset :: Cont r r -> Cont r' r #

reset m delimits the continuation of any shift inside m.

liftLocal :: Monad m => m r' -> ((r' -> r') -> m r -> m r) -> (r' -> r') -> ContT r m a -> ContT r m a #

liftLocal ask local yields a local function for ContT r m.

evalContT :: Monad m => ContT r m r -> m r #

The result of running a CPS computation with return as the final continuation.

evalCont :: Cont r r -> r #

The result of running a CPS computation with the identity as the final continuation.

updateContT :: (m r -> m r) -> ContT r m () Source #

stateToReaderContT :: Monad m => StateT s m a -> ContT r (ReaderT s m) a 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 # 
Instance details

Methods

hasTransConstraint :: forall (m :: Type -> Type). MonadFail m => Dict (MonadFail (ContT s m)) Source #

TransConstraint MonadIO (ContT s) Source # 
Instance details

Methods

hasTransConstraint :: forall (m :: Type -> Type). MonadIO m => Dict (MonadIO (ContT s m)) Source #

TransConstraint Applicative (ContT s) Source # 
Instance details

Methods

hasTransConstraint :: forall (m :: Type -> Type). Applicative m => Dict (Applicative (ContT s m)) Source #

TransConstraint Functor (ContT s) Source # 
Instance details

Methods

hasTransConstraint :: forall (m :: Type -> Type). Functor m => Dict (Functor (ContT s m)) Source #

TransConstraint Monad (ContT s) Source # 
Instance details

Methods

hasTransConstraint :: forall (m :: Type -> Type). Monad m => Dict (Monad (ContT s m)) Source #

MonadTransCoerce (ContT r) Source # 
Instance details

Methods

transCoerce :: forall (m1 :: Type -> Type) (m2 :: Type -> Type). Coercible m1 m2 => Dict (Coercible (ContT r m1) (ContT r m2)) Source #

MonadCont (ContT r m) Source # 
Instance details

Methods

callCC :: ((a -> ContT r m b) -> ContT r m a) -> ContT r m a Source #