~/bend-docscommunity

defs.bend checks

raw source on the hub · import lawful-halves@0.1.0.1/defs.bend as Defs

1 import
import Base

Types

type Task source · line 15 · raw

@-b:Quant -> @-B:Kind(b) -> Type

A task: a closure that holds its own input. (A datatype rather than a bare closure: proofs then move tasks around as values. A closure passed as an argument is eta-expanded by bend's elaborator, which the --verdict kernel does not accept.)

type Tree source · line 33 · raw

@-a:Quant -> @-A:Kind(a) -> Kind(a)

A binary tree of values: none (Tip), one (Leaf), or two subtrees (Node).

Definitions

def call source · line 19 · raw

@-b:Quant -> @-B:Kind(b) -> @t:Task<b, B> -> B

What the task gives.

def force source · line 25 · raw

@-b:Quant -> @-B:Kind(b) -> @ts:List<&1, Task<b, B>> -> List<b, B>

Each task called once, in order: the list of their results.

def leaves source · line 39 · raw

@-a:Quant -> @-A:Kind(a) -> @t:Tree<a, A> -> List<a, A>

The values of t, left to right.

def shape source · line 49 · raw

@-a:Quant -> @-A:Kind(a) -> @t:Tree<a, A> -> Tree<&2, Unit>

The shape of t: the same tree with every value replaced by Unit{}.

def count source · line 59 · raw

@+s:Tree<&2, Unit> -> Nat

The number of leaves of a shape.

def balanced source · line 71 · raw

@+s:Tree<&2, Unit> -> Bool

A balanced shape: at every Node, the left subtree has at least one leaf, and the right one has as many leaves as the left or one more. So no Tip sits below a Node, and a tree of n >= 1 leaves is ceil(log2(n)) levels deep.