decepticon/stateful

Types

pub type State(a, s) {
  State(run: fn(s) -> #(a, s))
}

Constructors

  • State(run: fn(s) -> #(a, s))

Functions

pub fn action(action_value: a) -> State(a, b)
pub fn apply(
  prev: State(fn(a) -> b, c),
  next: State(a, c),
) -> State(b, c)
pub fn do(
  over state: State(a, b),
  with and_then_fn: fn(a) -> State(c, b),
) -> State(c, b)
pub fn eval(state: State(a, b), initial: b) -> a
pub fn exec(state: State(a, b), initial: b) -> b
pub fn get() -> State(a, a)
pub fn increment_state() -> State(Nil, Int)
pub fn map(
  over state: State(a, b),
  with map_fn: fn(a) -> c,
) -> State(c, b)
pub fn put(state_value: a) -> State(Nil, a)
pub fn run(state: State(a, b), initial: b) -> #(a, b)
Search Document