Copyright | (c) 2020 Microsoft Research; Daan Leijen; Ningning Xie |
---|---|
License | MIT |
Maintainer | xnning@hku.hk; daan@microsoft.com |
Stability | Experimental |
Safe Haskell | None |
Language | Haskell2010 |
Primitive module that implements type safe multi-prompt control. Used by the Control.Ev.Eff module to implement effect handlers.
Markers
An abstract prompt marker
markerEq :: Marker a -> Marker b -> Bool Source #
Compare two markers of different types for equality
Control monad
The Multi Prompt control monad,
with existentials ans
and b
: where ans
is the answer type, i.e. the type of the handler/prompt context,
and b
the result type of the operation.
Pure !a | Pure results (only exported for use in the Control.Ev.Eff module) |
Run a control monad. This may fail with an "unhandled operation"
error if
there is a yield
to a marker that escaped its prompt scope.
yield :: Marker ans -> ((b -> Ctl ans) -> Ctl ans) -> Ctl b Source #
yield m op
yields to a specific marker and calls op
in that context
with a resumption k :: b -> Ctl ans
that resumes at the original call-site
with a result of type b
. If the marker is no longer in the evaluation context,
(i.e. it escaped outside its prompt) the yield
fails with an "unhandled operation"
error.