Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- type (?) h a = CPS (Result h) ((->) h) a
- class Handles (h :: Type) (op :: j -> k -> Type) where
- type family Result (h :: Type) :: Type
- type family Return (opApp :: Type) :: Type
- handle :: (h ? a) -> (a -> h -> Result h) -> h -> Result h
- whynot :: (h `Handles` op, e ~ Ex h op) => op e u -> h ? Return (op e u)
Documentation
type (?) h a = CPS (Result h) ((->) h) a Source #
Girard's "why not?" monad parameterized by an effect h
andler.
((->) h)
is equivalent to the Reader
monad where computations have
access to effect handlers.
The purpose of the Handles
typeclass is to keep track of the accumulated
constraints imposed on h
as an effect computation is evaluated.
Since CPS
is a control-flow monad which can lift
any arbitrary effects
from m
(when m
is a monad) we are effectively have constructed an effect
routing monad which may not be able to actually perform all the effects, but
nonetheless account for them in the types in the form of constraints.
class Handles (h :: Type) (op :: j -> k -> Type) where Source #
A predicate indicating that the handler type h
can perform the side-
effects of the action op
.
clause :: e ~ Ex h op => op e u -> (Return (op e u) -> h -> Result h) -> h -> Result h Source #
Handles an action and applies the continuation to it.
Instances
type family Result (h :: Type) :: Type Source #
The result of the effect.
Instances
type Result (ExceptHandler err a) Source # | |
Defined in Demos | |
type Result (StateHandler s a) Source # | |
Defined in Demos | |
type Result (FStateHandler h s a) Source # | |
Defined in Demos | |
type Result (StateExceptHandler err s a) Source # | |
Defined in Demos |