effin-0.3.0.3: A Typeable-free implementation of extensible effects

Control.Effect.State

Contents

Synopsis

# Documentation

class MemberEffect State (State s) l => EffectState s l Source #

Instances

 MemberEffect (* -> * -> *) State (State s) l => EffectState s l Source #

data State s a Source #

An effect where a state value is threaded throughout the computation.

Instances

 type Is (* -> * -> *) State f Source # type Is (* -> * -> *) State f

runState :: s -> Effect (State s :+ l) a -> Effect l (a, s) Source #

Completely handles a State effect by providing an initial state, and making the final state explicit.

evalState :: s -> Effect (State s :+ l) a -> Effect l a Source #

Completely handles a State effect, and discards the final state.

execState :: s -> Effect (State s :+ l) a -> Effect l s Source #

Completely handles a State effect, and discards the final value.

get :: EffectState s l => Effect l s Source #

Gets the current state.

gets :: EffectState s l => (s -> a) -> Effect l a Source #

Gets a value that is a function of the current state.

put :: EffectState s l => s -> Effect l () Source #

Replaces the current state.

modify :: EffectState s l => (s -> s) -> Effect l () Source #

Applies a pure modifier to the state value.

modify' :: EffectState s l => (s -> s) -> Effect l () Source #

Applies a pure modifier to the state value. The modified value is converted to weak head normal form.

state :: EffectState s l => (s -> (a, s)) -> Effect l a Source #

Lifts a stateful computation to the Effect monad.

withState :: EffectState s l => (s -> s) -> Effect l a -> Effect l a Source #

Runs a computation with a modified state value.

withState f x = modify f >> x

# Orphan instances

 (Member (* -> *) (State s) l, (~) (* -> *) (State s) (InstanceOf (* -> * -> *) State l)) => MonadState s (Effect l) Source # Methodsget :: Effect l s #put :: s -> Effect l () #state :: (s -> (a, s)) -> Effect l a #