Tree

sealed interface Tree(source)

The tree of a program under finite response sets. A program is a value: a tree whose nodes are the effects it performs and whose edges are the responses it may receive, with a return value at every leaf. Nothing in the value says what an effect does; the handlers applied to it decide that when it runs, and one run under one stack is a Trace. The tree is the program itself, unfolded: an effect whose response type is finite (Boolean, an enum, a sealed hierarchy of objects, Unit) under every response, an effect whose response type is infinite under the Representatives the caller names, and an effect that can have no response at all, such as a failure, as a leaf. tree builds it.

Inheritors

Types

Link copied to clipboard
sealed interface Leaf : Tree

Where a path ends.

Link copied to clipboard
data class Returns(val value: Any?) : Tree.Leaf

The program finished with value.

Link copied to clipboard
data class Step(val effect: Effect<*>, val branches: List<Branch>) : Tree

An effect and the subtree under each of its responses, in the order the responses were given.

Link copied to clipboard
data class Stops(val effect: Effect<*>) : Tree.Leaf

The program performed an effect that has no response, such as a failure, so it goes no further.

Functions

Link copied to clipboard

The tree as a Mermaid flowchart: effects as boxes, leaves as terminals, responses on the edges, and a subtree that would be drawn exactly like one already drawn shares its node.

Link copied to clipboard

Every path of the tree, in the order the branches were given.

Link copied to clipboard

The responses that opened no path of their own: at an effect, a response whose subtree has the shape of an earlier response's, the shape of a subtree being its effects by class and its leaves by outcome, with responses and effect arguments ignored. Such a response adds no effect and no outcome a reader could not reach through its sibling. The representatives of an infinite response type are well chosen when none of them is listed here.