effect-handlers-0.1.0.8: A library for writing extensible algebraic effects and handlers. Similar to extensible-effects but with deep handlers.

Safe HaskellNone
LanguageHaskell2010

Control.Effects.State

Synopsis

Documentation

data State s a Source #

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

Methods

fmap :: (a -> b) -> State s a -> State s b #

(<$) :: a -> State s b -> State s a #

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

Read from state

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

Write to state

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

Lift a function into state

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

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