handleS
inline fun <E : Effect<*>, S, A> Program<A>.handleS(initialState: S, noinline rule: suspend ProgramScope.(S, E) -> Pair<S, Any?>): Program<A>(source)
Stateful handle: the block receives the current state and returns newState to response. Mind the pair order when the state and the response share a type — response to newState is equally well-typed and silently swaps the two. The state is threaded by value, so each interpretation starts from initialState and shares nothing with another; a rule that mutates the initial state in place instead of returning a new one shares it between every interpretation of the program.