polysemy-0.1.1.0: Higher-order, low-boilerplate, zero-cost free monads.

Safe HaskellNone
LanguageHaskell2010

Polysemy.State

Contents

Synopsis

Effect

data State s m a where Source #

An effect for providing statefulness. Note that unlike mtl's StateT, there is no restriction that the State effect corresponds necessarily to local state. It could could just as well be interrpeted in terms of HTTP requests or database access.

Interpreters which require statefulness can reinterpret themselves in terms of State, and subsequently call runState.

Constructors

Get :: State s m s 
Put :: s -> State s m () 
Instances
type DefiningModule (State :: Type -> k -> Type -> Type) Source # 
Instance details

Defined in Polysemy.State

type DefiningModule (State :: Type -> k -> Type -> Type) = "Polysemy.State"

Actions

get :: forall s. forall r. Member (State s) r => Semantic r s Source #

gets :: Member (State s) r => (s -> a) -> Semantic r a Source #

put :: forall s. forall r. Member (State s) r => s -> Semantic r () Source #

modify :: Member (State s) r => (s -> s) -> Semantic r () Source #

Interpretations

runState :: Typeable s => s -> Semantic (State s ': r) a -> Semantic r (s, a) Source #

Run a State effect with local state.

runLazyState :: Typeable s => s -> Semantic (State s ': r) a -> Semantic r (s, a) Source #

Run a State effect with local state, lazily.