garden
Safe HaskellSafe-Inferred
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 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.

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

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 #

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 (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 (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 #

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 (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 (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) 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 #

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

The result of the effect.

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

Defined in Demos

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

Defined in Demos

type Result (StateExceptHandler err s a) = (s, Either err a)

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

The immediate value returned from an effect invocation.

Instances

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

Defined in Demos

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

Defined in Demos

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

Defined in Demos

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

Defined in Demos

type Return (Throw err a) = a

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

A synonym of (#) for clarity.

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

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