- data CC p m a
- type SubCont p m a b = CC p m a -> CC p m b
- type CCT p m a w = SubCont p m a w -> CC p m w
- type Prompt p m w = (forall x. CCT p m x w -> p m x, forall x. p m x -> Maybe (CCT p m x w))
- pushPrompt :: Monad m => Prompt p m w -> CC p m w -> CC p m w
- takeSubCont :: Monad m => Prompt p m w -> CCT p m x w -> CC p m x
- pushSubCont :: Monad m => SubCont p m a b -> CC p m a -> CC p m b
- runCC :: Monad m => CC (p :: (* -> *) -> * -> *) m a -> m a
- abortP :: Monad m => Prompt p m w -> CC p m w -> CC p m any
- shiftP :: Monad m => Prompt p m w -> ((a -> CC p m w) -> CC p m w) -> CC p m a
- shift0P :: Monad m => Prompt p m w -> ((a -> CC p m w) -> CC p m w) -> CC p m a
- controlP :: Monad m => Prompt p m w -> ((a -> CC p m w) -> CC p m w) -> CC p m a
- data PS w m x
- ps :: Prompt (PS w) m w
- data P2 w1 w2 m x
- p2L :: Prompt (P2 w1 w2) m w1
- p2R :: Prompt (P2 w1 w2) m w2
- data PP m x
- pp :: Typeable w => Prompt PP m w
- data PM c m x
- pm :: Typeable w => Prompt (PM c) m w
- data PD m x
- newPrompt :: Typeable w => Int -> Prompt PD m w
- as_prompt_type :: Prompt p m w -> w -> Prompt p m w
Documentation
Delimited-continuation monad transformer It is parameterized by the prompt flavor p The first argument is the regular (success) continuation, the second argument is the bubble, or a resumable exception
type Prompt p m w = (forall x. CCT p m x w -> p m x, forall x. p m x -> Maybe (CCT p m x w))Source
Generalized prompts for the answer-type w: an injection-projection pair
pushPrompt :: Monad m => Prompt p m w -> CC p m w -> CC p m wSource
Basic Operations of the delimited control interface
pushSubCont :: Monad m => SubCont p m a b -> CC p m a -> CC p m bSource
Apply the captured continuation
The extreme case: prompts for the single answer-type w. The monad (CC PS) then is the monad for regular (single-prompt) delimited continuations
There is only one generalized prompt of the flavor PS for a given answer-type w. It is defined below
Prompts for the closed set of answer-types The following prompt flavor P2, for two answer-types w1 and w2, is given as an example. Typically, a programmer would define their own variant data type with variants for the answer-types that occur in their program.
The same as PP but with the phantom parameter c
The parameter is useful to statically enforce various constrains
(statically pass some information between shift and reset)
The prompt PP is too dynamic
: all errors are detected dynamically
See Generator2.hs for an example
Open set of answer types, with an additional distinction (given by integer identifiers) This prompt flavor corresponds to the prompts in the Dybvig, Peyton-Jones, Sabry framework (modulo the Typeable constraint).
as_prompt_type :: Prompt p m w -> w -> Prompt p m wSource
It is often helpful, for clarity of error messages, to specify the answer-type associated with the prompt explicitly (rather than relying on the type inference to figure that out). The following function is useful for that purpose.