extensible-effects-1.10.0.1: An Alternative to Monad Transformers

Safe HaskellSafe
LanguageHaskell2010

Control.Eff.Operational

Contents

Description

Operational Monad (https://wiki.haskell.org/Operational) implemented with extensible effects.

Synopsis

Documentation

data Program instr v Source

Lift values to an effect. You can think this is a generalization of Lift.

Constructors

forall a . Program (instr a) (a -> v) 

Instances

Functor (Program instr) 
Typeable ((* -> *) -> * -> *) Program 

singleton :: (Typeable instr, Member (Program instr) r) => instr a -> Eff r a Source

Lift a value to a monad.

runProgram :: Typeable f => (forall x. f x -> Eff r x) -> Eff (Program f :> r) a -> Eff r a Source

Convert values using given interpreter to effects.

Usage

See Example for an example of defining data using GADTs and implementing interpreters from the data to effects.

To use the interpreter, see below or consult the tests.

main :: IO ()
main = do
    putStrLn . fst . run . runMonoidWriter . evalState ["foo","bar"] $ runProgram adventPure prog
    runLift $ runProgram adventIO prog