ProgramScope

sealed class ProgramScope(source)

Receiver scope of program blocks: sequence sub-programs, and effects, with bind. Suspension is restricted, so only binds — not arbitrary suspend calls — can occur inside.

Functions

Link copied to clipboard
suspend fun <R> Effect<R>.bind(): R

Perform this effect as the next step of the enclosing block and return its response. An effect is the one-step program perform makes of it, so effect.bind() is perform(effect).bind(), under the same single-shot rule.

suspend fun <A> Program<A>.bind(): A

Run this sub-program as the next step of the enclosing block and return its value. A block's continuation is single-shot: binding a multi-shot effect (such as a choice under collectAll) directly in a block fails when it is resumed twice.