Copyright | (c) R. Kent Dybvig, Simon L. Peyton Jones and Amr Sabry |
---|---|

License | MIT |

Maintainer | Dan Doel |

Stability | Experimental |

Portability | Non-portable (generalized algebraic datatypes) |

Safe Haskell | None |

Language | Haskell98 |

A monadic treatment of delimited continuations.

Adapted from the paper
*A Monadic Framework for Delimited Continuations*,
by R. Kent Dybvig, Simon Peyton Jones and Amr Sabry
(http://www.cs.indiana.edu/~sabry/papers/monadicDC.pdf)

This module implements the generalized sequence type used as a stack of frames representation of the delimited continuations.

- data Seq seg ans a where
- type SubSeq seg ans a b = Seq seg ans b -> Seq seg ans a
- appendSubSeq :: SubSeq seg ans a b -> SubSeq seg ans b c -> SubSeq seg ans a c
- pushSeq :: SubSeq seg ans a b -> Seq seg ans b -> Seq seg ans a
- splitSeq :: Prompt ans b -> Seq seg ans a -> (SubSeq seg ans a b, Seq seg ans b)

# Sequence datatype

data Seq seg ans a where Source

This is a generalized sequence datatype, parameterized by three types: seg : A constructor for segments of the sequence.

ans : the type resulting from applying all the segments of the sequence. Also used as a region parameter.

a : The type expected as input to the sequence of segments.

# Sub-sequences

type SubSeq seg ans a b = Seq seg ans b -> Seq seg ans a Source

A type representing a sub-sequence, which may be appended to a sequence of appropriate type. It represents a sequence that takes values of type a to values of type b, and may be pushed onto a sequence that takes values of type b to values of type ans.

appendSubSeq :: SubSeq seg ans a b -> SubSeq seg ans b c -> SubSeq seg ans a c Source

Concatenate two subsequences