Reference
Auto-generated API reference from nix-effects source.

State

Mutable state effect: get/put/modify with standard handler.

get

Read the current state. Returns a Computation that, when handled, yields the current state value.

get : Computation s

gets

Read a projection of the current state.

gets : (s -> a) -> Computation a

handler

Standard state handler. Interprets get/put/modify effects. Use with trampoline.handle:

handle { handlers = state.handler; state = initialState; } comp
  • get: returns current state as value
  • put: replaces state with param, returns null
  • modify: applies param (a function) to state, returns null

modify

Apply a function to the current state. Returns a Computation that, when handled, transforms the state via f and returns null.

modify : (s -> s) -> Computation null

put

Replace the current state. Returns a Computation that, when handled, sets the state to the given value and returns null.

put : s -> Computation null