The result of running a State: the value paired with the final state.
State
[A, S] matches the order of Haskell's runState result, (a, s), even though the type parameters read state first, as in State<S, A>.
[A, S]
runState
(a, s)
State<S, A>
The state type.
The value type.
import { State, type StatePair } from '@b-jones-rfd/func-help'const [value, state]: StatePair<number, string> = State.gets( (n: number) => `count: ${n}`,).run(3) Copy
import { State, type StatePair } from '@b-jones-rfd/func-help'const [value, state]: StatePair<number, string> = State.gets( (n: number) => `count: ${n}`,).run(3)
The result of running a
State: the value paired with the final state.[A, S]matches the order of Haskell'srunStateresult,(a, s), even though the type parameters read state first, as inState<S, A>.