leviathan
Types
Functions
pub fn do(
st: State(a, b),
f: fn(b) -> State(a, c),
) -> State(a, c)
Monadic bind (>>=) that allows you to use gleam’s use
syntax as a replacement for do
notation
pub fn eval(st: State(a, b), initial: a) -> b
Apply a state function st
to an initial state and just return the computation’s result
pub fn exec(st: State(a, b), with initial: a) -> a
Apply a state function st
to an initial state and return the final state
pub fn go(st: State(a, b), initial: a) -> #(b, a)
Apply a state function st
to an initial state and return a pair of a value and the final state
pub fn map(st: State(a, b), f: fn(b) -> c) -> State(a, c)
Apply the function f
to the resulting value of s
pub fn modify(f: fn(a) -> a) -> State(a, Nil)
Apply the function f
to the current state
Replaces the return value with Nil
pub fn put(x: a) -> State(a, Nil)
Sets the state value to a given state x
Replaces the return value with Nil