pub enum Term {
Show 16 variants
Int(i64),
Fix(i64),
Bool(bool),
Text(String),
Var(u32),
Let(Box<Term>, Box<Term>),
If(Box<Term>, Box<Term>, Box<Term>),
Prim(PrimOp, Vec<Term>),
Rec(BTreeMap<String, Term>),
Get(Box<Term>, String),
ListNew(Vec<Term>),
Call(WeftHash, Vec<Term>),
Effect(EffectKind, BTreeMap<String, Term>),
Map {
cap: u32,
list: Box<Term>,
body: Box<Term>,
},
Fold {
cap: u32,
list: Box<Term>,
init: Box<Term>,
body: Box<Term>,
},
Iota {
cap: u32,
count: Box<Term>,
},
}Expand description
The term graph. Variables are de Bruijn indices (0 = innermost binder); a definition’s parameters are the outermost binders, in order.
Variants§
Int(i64)
Fix(i64)
Fixed-point literal (raw millionths — Term::Fix(1_500_000) is 1.5).
Bool(bool)
Text(String)
Var(u32)
de Bruijn index into the binder stack.
Let(Box<Term>, Box<Term>)
Bind the first term’s value; evaluate the second with it as index 0.
If(Box<Term>, Box<Term>, Box<Term>)
Prim(PrimOp, Vec<Term>)
Rec(BTreeMap<String, Term>)
Record construction; field order is canonical (sorted) via BTreeMap.
Get(Box<Term>, String)
Field projection.
ListNew(Vec<Term>)
Call(WeftHash, Vec<Term>)
Call another definition by hash — the only kind of call.
Effect(EffectKind, BTreeMap<String, Term>)
Construct an effect request (an [Action] value). Pure.
Map
Bounded map: evaluate body (element = Var 0) for each of at most
cap elements of list — elements beyond the cap are dropped. The
cap is what keeps the fuel bound static: totality never bends.
Fold
Bounded fold: thread an accumulator through at most cap elements
(body sees acc = Var 1, element = Var 0).
Iota
The list 0..min(count, cap) — the generator’s seed. cap keeps the
fuel bound static; with Map/Fold it makes rings, grids, and spirals.