runState -package:fused-effects

Unwrap a state monad computation as a function. (The inverse of state.)
Run a State effect with local state.
Unwrap a state monad computation as a function. (The inverse of state.)
Encapsulation of a state-using computation, exposing the initial and final states. Typical usage in arrow notation:
proc p -> do
...
(result, final_state) <- (|runState cmd|) init_state
Run the State effect with the given initial state and return the final value along with the final state.
Run a State effect
Run a State effect
Handler for State effects.
Run a State effect with local state.
>>> runPureEff $ runState 10 $ \st -> do
n <- get st
pure (2 * n)
(20,10)
Interpret the State effect.
This is the state record that controls the output style.
Runs a monadic generating action in the State monad using a pure pseudo-random number generator.

Examples

>>> import System.Random.Stateful

>>> let pureGen = mkStdGen 137

>>> runStateGen pureGen randomM :: (Int, StdGen)
(7879794327570578227,StdGen {unStdGen = SMGen 11285859549637045894 7641485672361121627})
Runs a monadic generating action in the ST monad using a pure pseudo-random number generator.
Runs a monadic generating action in the ST monad using a pure pseudo-random number generator. Same as runStateGenST, but discards the resulting generator.
Runs a monadic generating action in the StateT monad using a pure pseudo-random number generator.

Examples

>>> import System.Random.Stateful

>>> let pureGen = mkStdGen 137

>>> runStateGenT pureGen randomM :: IO (Int, StdGen)
(7879794327570578227,StdGen {unStdGen = SMGen 11285859549637045894 7641485672361121627})
Runs a monadic generating action in the StateT monad using a pure pseudo-random number generator. Returns only the resulting pseudo-random value.

Examples

>>> import System.Random.Stateful

>>> let pureGen = mkStdGen 137

>>> runStateGenT_ pureGen randomM :: IO Int
7879794327570578227
Runs a monadic generating action in the State monad using a pure pseudo-random number generator. Returns only the resulting pseudo-random value.

Examples

>>> import System.Random.Stateful

>>> let pureGen = mkStdGen 137

>>> runStateGen_ pureGen randomM :: Int
7879794327570578227