effect-handlers-0.1.0.0

Safe HaskellNone
LanguageHaskell2010

Control.Effects.Cont.State

Synopsis

Documentation

This module provides the familiar state effect.

data State s a

The functor representing the effect. You shouldn't need to create this manually, just use get, put or state.

Constructors

SGet (s -> a) 
SPut s a 

Instances

Functor (State s) 
Typeable (* -> * -> *) State 

get :: (Member (State a) r, Typeable a) => Eff r a

Read from state

put :: (Member (State s) r, Typeable s) => s -> Eff r ()

Write to state

state :: (Member (State s) r, Typeable s) => (s -> (a, s)) -> Eff r a

Lift a function into state

stateHandler :: Handler (State s) r a (s -> Eff r a)

Handle state into a function. Note that applying the resulting function you get out another program that you have to bind over.