monadology-0.4: The best ideas in monad-related classes and types.
Safe HaskellNone
LanguageGHC2021

Control.Monad.Ology.Specific.ContT

Synopsis

Documentation

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:

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

reset m delimits the continuation of any shift inside m.

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)

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 #

Lifting MonadIO (ContT r :: (Type -> Type) -> Type -> Type) 
Instance details

Defined in Data.Constraint.Lifting

Methods

lifting :: forall (a :: Type -> Type). MonadIO a :- MonadIO (ContT r a) #

Lifting Applicative (ContT r :: (Type -> Type) -> Type -> Type) 
Instance details

Defined in Data.Constraint.Lifting

Methods

lifting :: forall (a :: Type -> Type). Applicative a :- Applicative (ContT r a) #

Lifting Functor (ContT r :: (Type -> Type) -> Type -> Type) 
Instance details

Defined in Data.Constraint.Lifting

Methods

lifting :: forall (a :: Type -> Type). Functor a :- Functor (ContT r a) #

Lifting Monad (ContT r :: (Type -> Type) -> Type -> Type) 
Instance details

Defined in Data.Constraint.Lifting

Methods

lifting :: forall (a :: Type -> Type). Monad a :- Monad (ContT r a) #

Lifting (MonadReader r :: (Type -> Type) -> Constraint) (ContT r' :: (Type -> Type) -> Type -> Type) 
Instance details

Defined in Data.Constraint.Lifting

Methods

lifting :: forall (a :: Type -> Type). MonadReader r a :- MonadReader r (ContT r' a) #

Lifting (MonadState s :: (Type -> Type) -> Constraint) (ContT r' :: (Type -> Type) -> Type -> Type) 
Instance details

Defined in Data.Constraint.Lifting

Methods

lifting :: forall (a :: Type -> Type). MonadState s a :- MonadState s (ContT r' 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 #

Generic (ContT r m a) 
Instance details

Defined in Control.Monad.Trans.Cont

Associated Types

type Rep (ContT r m a) 
Instance details

Defined in Control.Monad.Trans.Cont

type Rep (ContT r m a) = D1 ('MetaData "ContT" "Control.Monad.Trans.Cont" "transformers-0.6.1.0-inplace" 'True) (C1 ('MetaCons "ContT" 'PrefixI 'True) (S1 ('MetaSel ('Just "runContT") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ((a -> m r) -> m r))))

Methods

from :: ContT r m a -> Rep (ContT r m a) x #

to :: Rep (ContT r m a) x -> ContT r m a #

type Rep (ContT r m a) 
Instance details

Defined in Control.Monad.Trans.Cont

type Rep (ContT r m a) = D1 ('MetaData "ContT" "Control.Monad.Trans.Cont" "transformers-0.6.1.0-inplace" 'True) (C1 ('MetaCons "ContT" 'PrefixI 'True) (S1 ('MetaSel ('Just "runContT") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ((a -> m r) -> m r))))

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)

evalCont :: Cont r r -> r #

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

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

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

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

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

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

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

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.

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.

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.

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:

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.

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 # 
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 #