Skip to main content

run

Function run 

Source
pub fn run<A: IVm>(
    effect: Any<A>,
    perform: impl FnMut(Any<A>, Any<A>) -> Result<Any<A>, Any<A>>,
) -> Result<Any<A>, Any<A>>
Expand description

Performs effect to its result.

A Pure is called with no arguments and answers its complete FJS Result, ['ok', v] or ['error', e], unchanged. A Do is handed to perform, as its command and payload, and the complete answer, an error included, goes to its continuation, which gives the next effect. perform is the synchronous boundary where an operation happens; what it does is not the loop’s.

The outer Result is the VM’s, which is different: Err is a language throw, from perform or from any function the loop calls, and ends the run with the value thrown.

The loop is a loop: one effect after another takes no more stack than one.