state
Source: /nix/store/mls72plk3raskl1r5afh3cl9ik3rn969-source/nix/state.nix
Module Description
Built-in state effect providing get/set/modify operations.
The state effect is a fundamental capability that allows reading and writing to a mutable state. In NFX, state is managed through the context mechanism - the state IS the context.
Namespace Contents
get- Reads the current stateset- Replaces the state with a new valuemodify- Transforms state with a pure functionmodifyM- Transforms state with an effectful function
Example
provide 10 (
mapM (old:
then' (state.get)
(state.modify (x: x + 1))
) state.get
) # State goes 10 -> 11, returns 11
See Also
func- Alternative for read-only state accesscontext- For named attribute-based state
Combinators
Generated from /nix/store/mls72plk3raskl1r5afh3cl9ik3rn969-source/nix/state.nix