pub enum Expr {
Show 16 variants
Int(BigInt),
Unit,
List(Vec<Expr>),
Name(Text),
Local {
name: Box<Text>,
index: u32,
},
Builtin(Builtin),
ModItem {
name: Box<Text>,
index: u32,
depth: u32,
},
Recur(Rc<ModuleData>),
Symbol(Text),
Str(Text),
App(Box<[Expr]>),
Abs(Rc<Lambda>),
Map(Vec<(Expr, Expr)>),
Home {
leaf: HomeLeaf,
depth: u32,
},
Block(Box<[(Option<Pattern>, Expr)]>),
Case {
subject: Rc<Expr>,
cases: Box<[(Pattern, Expr)]>,
},
}Expand description
An Elly expression for the initial subset. Strings and records are deferred per the spec.
Variants§
Int(BigInt)
Arbitrary-precision integer literal parsed from tokens (0, -123, 0xCAFE).
Unit
The unit value (). Used as a nullary marker in chains (f ()), standalone,
or as empty-value sugar in maps ({ .k: }). Matches Pattern::Unit.
Rendered as ().
List(Vec<Expr>)
Runtime list literal from Muon #-prefixed brackets (#[…]). Supports
any arity, including empty #[ ] or single-element #[e]. Grouping
parentheses (…) are handled at parse time.
Name(Text)
Unresolved reference to a binding or free name. The resolver rewrites
in-scope names to Expr::Local and rejects others. Evaluator only
sees Local.
Local
Resolved reference using a de Bruijn index. The environment is a cons
list of bindings (innermost first); index is the distance from the top.
The original name is boxed and kept for rendering to keep Expr at four words.
Builtin(Builtin)
A __-builtin resolved at parse time via Builtin::from_name. Since __
names are unbindable, this avoids environment lookups at runtime. Renders
as the Name it replaces.
ModItem
Reference to an item in the enclosing module. Resolved by
resolve_module_bodies. Evaluated via the home module in the environment.
index is the item’s position in the sorted item table. depth is the
number of Module terminals to skip. name is
boxed for size.
Recur(Rc<ModuleData>)
Recursive binding group: recur (a = va, b = vb) e. Bindings are simultaneous
and mutually visible. The group is treated as a module where bindings are
items and the scoped expression is the module body. See
docs/done/2026-08-13_elly-recur.md.
Symbol(Text)
Dotted literal (.foo, .0), stored without the leading dot.
Str(Text)
UTF-8 string literal decoded from Muon <str>. Evaluates to Value::Str.
Rendered as a quoted literal.
App(Box<[Expr]>)
Flattened call spine: index 0 is the callee, [1..] are arguments. Covers
both standard and spread calls. Evaluated via apply_n in eval.rs. Holds
at least two elements; currying is handled by the evaluator.
Abs(Rc<Lambda>)
Abstraction &<pattern> body. The Lambda (patterns and body) is shared
via Rc. Multiple & parameters are collected into one Lambda. Evaluator
creates closures by capturing the environment. Renders as nested (abs …)
for stability.
Map(Vec<(Expr, Expr)>)
Map literal from Muon #{ … }. Entries are (key, value) pairs in source
order. Keys are evaluated at runtime.
Home
Reference to the home module: Self, #Self(…), or x.Self. Found via the
environment’s terminal. depth is the number of Module terminals to skip.
See docs/done/2026-09-11_elly-v1-self.md.
Block(Box<[(Option<Pattern>, Expr)]>)
Sequence { c0, c1, …, e }, also the target for let. Clauses are evaluated
sequentially in a shared scope; the last clause’s value is the block’s result.
Represented explicitly to support future effects (e.g., break, defer).
Boxed to keep Expr at four words.
Case
Matching construct case <subject> { &p0 b0, ... }. Evaluates subject once
and executes the first matching arm’s body. Raises .no_match if no arms
match. Subjectless cases are lowered to &__arg (case __arg { ... }).