State package:polysemy

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.
Like interpret, but with access to an intermediate state s.
Run an State effect in terms of operations in IO. Internally, this simply creates a new IORef, passes it to runStateIORef, and then returns the result and the final value of the IORef. Note: This is not safe in a concurrent setting, as modify isn't atomic. If you need operations over the state to be atomic, use atomicStateToIO instead. Beware: As this uses an IORef internally, all other effects will have local state semantics in regards to State effects interpreted this way. For example, throw and catch will never revert puts, even if runError is used after stateToIO.
Run an State effect in terms of operations in ST. Internally, this simply creates a new STRef, passes it to runStateSTRef, and then returns the result and the final value of the STRef. Beware: As this uses an STRef internally, all other effects will have local state semantics in regards to State effects interpreted this way. For example, throw and catch will never revert puts, even if runError is used after stateToST. When not using the plugin, one must introduce the existential st type to stateToST, so that the resulting type after runM can be resolved into forall st. ST st (s, a) for use with runST. Doing so requires -XScopedTypeVariables.
stResult :: forall s a. (s, a)
stResult = runST ( (runM $ stateToST @_ @st undefined $ pure undefined) :: forall st. ST st (s, a) )
Get the stateful environment of the world at the moment the effect e is to be run. Prefer pureT, runT or bindT instead of using this function directly.
A variant of State that supports atomic operations.
Run a state action.
Run a state action.
A variant of atomicState in which the computation is strict in the new state and return value.
Run an AtomicState effect in terms of atomic operations in IO. Internally, this simply creates a new IORef, passes it to runAtomicStateIORef, and then returns the result and the final value of the IORef. Beware: As this uses an IORef internally, all other effects will have local state semantics in regards to AtomicState effects interpreted this way. For example, throw and catch will never revert atomicModifys, even if runError is used after atomicStateToIO.
Transform an AtomicState effect to a State effect, discarding the notion of atomicity.
Evaluate an AtomicState with local state semantics, discarding the notion of atomicity, by transforming it into State and running it with the provided initial state. @since v1.7.0.0
Execute an AtomicState with local state semantics, discarding the notion of atomicity, by transforming it into State and running it with the provided initial state. @since v1.7.0.0
Run an AtomicState effect by transforming it into atomic operations over an IORef.
Run an AtomicState effect by transforming it into atomic operations over a TVar.
Run an AtomicState with local state semantics, discarding the notion of atomicity, by transforming it into State and running it with the provided initial state. @since v1.7.0.0
Get the stateful environment of the world at the moment the Strategy is to be run. Prefer pureS, liftS, runS, or bindS instead of using this function directly.
Like interpret, but with access to an intermediate state s.
Run a State effect with local state, lazily.
Run a State effect with local state.
Run a State effect with local state, lazily.