garden
Safe HaskellSafe
LanguageHaskell2010

WhyNot

Synopsis

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 have effectively constructed an effect routing monad which may not be able to actually perform all the effects, but nonetheless accounts 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 operator op.

Associated Types

type Ex h op :: j Source #

tbd this removes the need for a fundep

Methods

clause :: e ~ Ex h op => op e u -> (Return (op e u) -> h -> Result h) -> h -> Result h Source #

Handles an operation and applies the continuation to it.

Instances

Instances details
Handles (ExceptHandler err a) Throw Source # 
Instance details

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) Save Source #

StateHandler also fulfills the Save operation.

Instance details

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 (StateHandler s a) Load Source #

StateHandler fulfills the Load operation.

Instance details

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 (StateExceptHandler err s a) Throw Source # 
Instance details

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 #

Handles (StateExceptHandler err s a) Save Source # 
Instance details

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) Load Source # 
Instance details

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 (FStateHandler h s a) Save Source # 
Instance details

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 (FStateHandler h s a) Load Source # 
Instance details

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 #

type family Result (h :: Type) :: Type Source #

The result of this effect handler.

Instances

Instances details
type Result (ExceptHandler err a) Source # 
Instance details

Defined in Demos

type Result (ExceptHandler err a) = Either err a
type Result (StateHandler s a) Source # 
Instance details

Defined in Demos

type Result (StateHandler s a) = (s, a)
type Result (StateExceptHandler err s a) Source # 
Instance details

Defined in Demos

type Result (StateExceptHandler err s a) = (s, Either err a)
type Result (FStateHandler h s a) Source # 
Instance details

Defined in Demos

type Result (FStateHandler h s a) = a

type family Return (opApp :: Type) :: Type Source #

An effect declares the return type of its operator by instantiating this.

Instances

Instances details
type Return (Yield s ()) Source # 
Instance details

Defined in Demos

type Return (Yield s ()) = ()
type Return (Await s ()) Source # 
Instance details

Defined in Demos

type Return (Await s ()) = s
type Return (Throw err a) Source # 
Instance details

Defined in Demos

type Return (Throw err a) = a
type Return (Save s ()) Source # 
Instance details

Defined in Demos

type Return (Save s ()) = ()
type Return (Load s ()) Source # 
Instance details

Defined in Demos

type Return (Load s ()) = s

handle :: (h ? a) -> (a -> h -> Result h) -> h -> Result h Source #

A synonym of (#) for readability.

whynot :: (h `Handles` op, e ~ Ex h op) => op e u -> h ? Return (op e u) Source #

Operator constructor. In delimited continuations terms, this is similar to shift.