| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
WhyNot
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 handler.
((->) 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.
Methods
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
| Handles (ExceptHandler err a) Throw Source # | |
Defined in Demos Associated Types type Ex (ExceptHandler err a) Throw :: j Source # Methods clause :: forall (e :: j) (u :: k). e ~ Ex (ExceptHandler err a) Throw => Throw e u -> (Return (Throw e u) -> ExceptHandler err a -> Result (ExceptHandler err a)) -> ExceptHandler err a -> Result (ExceptHandler err a) Source # | |
| Handles (StateHandler s a) Edit Source # | |
Defined in Demos Associated Types type Ex (StateHandler s a) Edit :: j Source # Methods clause :: forall (e :: j) (u :: k). e ~ Ex (StateHandler s a) Edit => Edit e u -> (Return (Edit e u) -> StateHandler s a -> Result (StateHandler s a)) -> StateHandler s a -> Result (StateHandler s a) Source # | |
| Handles (StateHandler s a) Load Source # |
|
Defined in Demos Associated Types type Ex (StateHandler s a) Load :: j Source # Methods clause :: forall (e :: j) (u :: k). e ~ Ex (StateHandler s a) Load => Load e u -> (Return (Load e u) -> StateHandler s a -> Result (StateHandler s a)) -> StateHandler s a -> Result (StateHandler s a) Source # | |
| Handles (StateHandler s a) Save Source # |
|
Defined in Demos Associated Types type Ex (StateHandler s a) Save :: j Source # Methods clause :: forall (e :: j) (u :: k). e ~ Ex (StateHandler s a) Save => Save e u -> (Return (Save e u) -> StateHandler s a -> Result (StateHandler s a)) -> StateHandler s a -> Result (StateHandler s a) Source # | |
| Handles (FStateHandler h s a) Load Source # | |
Defined in Demos Associated Types type Ex (FStateHandler h s a) Load :: j Source # Methods clause :: forall (e :: j) (u :: k). e ~ Ex (FStateHandler h s a) Load => Load e u -> (Return (Load e u) -> FStateHandler h s a -> Result (FStateHandler h s a)) -> FStateHandler h s a -> Result (FStateHandler h s a) Source # | |
| Handles (FStateHandler h s a) Save Source # | |
Defined in Demos Associated Types type Ex (FStateHandler h s a) Save :: j Source # Methods clause :: forall (e :: j) (u :: k). e ~ Ex (FStateHandler h s a) Save => Save e u -> (Return (Save e u) -> FStateHandler h s a -> Result (FStateHandler h s a)) -> FStateHandler h s a -> Result (FStateHandler h s a) Source # | |
| Handles (StateExceptHandler err s a) Load Source # | |
Defined in Demos Associated Types type Ex (StateExceptHandler err s a) Load :: j Source # Methods clause :: forall (e :: j) (u :: k). e ~ Ex (StateExceptHandler err s a) Load => Load e u -> (Return (Load e u) -> StateExceptHandler err s a -> Result (StateExceptHandler err s a)) -> StateExceptHandler err s a -> Result (StateExceptHandler err s a) Source # | |
| Handles (StateExceptHandler err s a) Save Source # | |
Defined in Demos Associated Types type Ex (StateExceptHandler err s a) Save :: j Source # Methods clause :: forall (e :: j) (u :: k). e ~ Ex (StateExceptHandler err s a) Save => Save e u -> (Return (Save e u) -> StateExceptHandler err s a -> Result (StateExceptHandler err s a)) -> StateExceptHandler err s a -> Result (StateExceptHandler err s a) Source # | |
| Handles (StateExceptHandler err s a) Throw Source # | |
Defined in Demos Associated Types type Ex (StateExceptHandler err s a) Throw :: j Source # Methods clause :: forall (e :: j) (u :: k). e ~ Ex (StateExceptHandler err s a) Throw => Throw e u -> (Return (Throw e u) -> StateExceptHandler err s a -> Result (StateExceptHandler err s a)) -> StateExceptHandler err s a -> Result (StateExceptHandler err s a) Source # | |
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 | |