runState

fun <S, A> Program<A>.runState(initial: S): Program<A>(source)

Handle every State operation with a state seeded from initial.

The state type is erased: the handler stores whatever State.Put carries and hands it back on State.Get, and getState trusts its caller about the type. A handler stack therefore carries one state type — this handler consumes every State operation above it, whatever type it was meant for, so an outer runState with a different type never sees them.