Copyright | (c) Ivan Lazar Miljenovic |
---|---|
License | 3-Clause BSD-style |
Maintainer | Ivan.Miljenovic@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
This module allows inclusion of ContT
into your monad stack so as to
represent continuation-passing style (CPS) computations.
Note that the behaviour of some monad transformers and how they deal
with continuations differs from how
mtl handles them. For
example, with a lazy state transformer, using this module results in
liftCallCC,
whereas mtl
uses
liftCallCC'.
- callCC :: forall m a b. HasCont m a b => ((a -> m b) -> m a) -> m a
- newtype ContT r m a :: * -> (* -> *) -> * -> * = ContT {
- runContT :: (a -> m r) -> m r
- type HasCont m a b = SatisfyConstraintF IsCont m a (ContFn b)
- class MonadLevel m => IsCont m
- type ContFn b = MkVarFn (Func (Func ValueOnly (MonadicOther b)) MonadicValue)
Documentation
callCC :: forall m a b. HasCont m a b => ((a -> m b) -> m a) -> m a Source
callCC
(call-with-current-continuation) calls a function with
the current continuation as its argument.
newtype ContT r m a :: * -> (* -> *) -> * -> *
The continuation monad transformer. Can be used to add continuation handling to other monads.
MonadTrans (ContT r) | |
MonadLevel m => ConstraintPassThrough (IsTransformer (ContT r)) (ListT m) True | |
MonadLevel m => ConstraintPassThrough (IsTransformer (StateT s)) (ContT r m) True | |
MonadLevel m => ConstraintPassThrough (IsTransformer (StateT s)) (ContT r m) True | |
MonadLevel m => ConstraintPassThrough (IsTransformer (ReaderT r)) (ContT c m) True | |
MonadTower m => ConstraintPassThrough (IsReader r) (ContT c m) True | |
MonadTower m => ConstraintPassThrough (IsState s) (ContT r m) True | |
Monad (ContT r m) | |
Functor (ContT r m) | |
Applicative (ContT r m) | |
MonadIO m => MonadIO (ContT r m) | |
MonadTower m => MonadLevel_ (ContT r m) | |
MonadTower m => MonadTower_ (ContT r m) | |
MonadTower m => IsCont (ContT r m) | |
type LowerMonad (ContT r m) = m | |
type WithLower_ (ContT r m) = AddIM | |
type AllowOtherValues (ContT r m) = False | |
type DefaultAllowConstraints (ContT r m) = False | |
type BaseMonad (ContT r m) = BaseMonad m | |
type InnerValue (ContT r m) a = r |
type HasCont m a b = SatisfyConstraintF IsCont m a (ContFn b) Source
class MonadLevel m => IsCont m Source
A simple class just to match up with the ContT
monad
transformer.
ValidConstraint IsCont | |
MonadTower m => ConstraintPassThrough IsCont (ListT m) True | |
MonadTower m => IsCont (ContT r m) | |
type ConstraintSatisfied IsCont m |
type ContFn b = MkVarFn (Func (Func ValueOnly (MonadicOther b)) MonadicValue) Source
This corresponds to
CallCC
in transformers
.