Source equations with normal continuations #
Stmt.evalWith observes the existing statement evaluation and runs its supplied
continuation only on normal completion. Actual returns and faults bypass that
continuation. The result uses ExceptT Fault (StateT Heap Part), retaining the
actual final heap even on a fault, and distinguishing finite fault from divergence.
Normal continuations receive the actual updated locals as ordinary arguments;
assignment does not introduce another state monad or hide changes at scope exit.
The equations below follow from the existing evaluation composition laws and mathlib's partial-value monad laws. They neither define another interpreter nor reprove source execution. In particular, a call uses the selected function's existing semantic result through genuine monadic bind; its body stays opaque.
Interpret the existing statement outcome with a normal continuation. A
returned value or fault exits immediately without evaluating next.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Assignment passes the updated local environment to the normal continuation. The native action still carries only the actual shared heap; lexical values are supplied directly rather than interpreted through a second state monad.
Return supplies its actual mathematical value and ignores the normal tail.
A primitive binding gives its actual value to the scoped body. Only normal scope exit removes that binding before invoking the outer continuation.
Allocation uses the existing native heap action and passes its actual fresh handle and extended heap to the scoped body. A later fault retains that body's final heap rather than rolling allocation back.
Node construction uses the existing native allocation action. Its fresh reference is bound in the actual extended heap, and only normal scope exit invokes the outer continuation; returns and faults keep their final heap.
Run the scope boundary before interpreting its control outcome. Only a
safe normal exit invokes next; a safe return keeps its value, and every fault
bypasses next with the boundary's actual final heap.
A checked current-heap read uses the native action and binds its actual scalar cell. Faults bypass both the scoped body and the normal continuation.
Node reading uses the same native typed lookup and passes its stored head and shared tail to the scoped body. Failure skips both continuations and keeps the actual current heap, rather than undoing earlier effects.
A source write is the existing native heap action followed by normal continuation at its actual updated heap. A failed write retains prior effects.
Borrowing checked slice metadata is native action composition, not a snapshot of the underlying object. The actual shared heap passes to the body.
Sequencing composes only normal continuations; an early return or fault in the first statement skips both the second statement and its normal tail.
Only the selected branch is evaluated, with the same normal continuation.
Optional values use native pattern matching. The selected some payload
is an ordinary argument to its branch, and normal completion passes the actual
updated outer locals to next. Returns and faults still bypass that tail.
A source call uses the actual callee action in ExceptT. Only a successful
callee return binds a value and runs the caller's scoped continuation. This
equation is not a simp rule, so recursive callee bodies remain opaque.
The existing function evaluation is its body's continuation observation with a missing-return fault on normal fallthrough, including Unit functions.