Skip to main content

Expr

Enum Expr 

Source
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.

Fields

§name: Box<Text>
§index: u32
§

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.

Fields

§name: Box<Text>
§index: u32
§depth: u32
§

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.

Fields

§depth: u32
§

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 { ... }).

Fields

§subject: Rc<Expr>
§cases: Box<[(Pattern, Expr)]>

Implementations§

Source§

impl Expr

Source

pub fn to_sexp(&self) -> String

Serialize to a compact s-expression, e.g. (app (name f) (name x)).

Source

pub fn to_json(&self) -> String

Serialize to compact, tagged JSON, e.g. {"app":[{"name":"f"},{"name":"x"}]}. Used by the elly-wasm playground to render the AST.

Trait Implementations§

Source§

impl Clone for Expr

Source§

fn clone(&self) -> Expr

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Expr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Expr

Source§

impl PartialEq for Expr

Source§

fn eq(&self, other: &Expr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Expr

Auto Trait Implementations§

§

impl !RefUnwindSafe for Expr

§

impl !Send for Expr

§

impl !Sync for Expr

§

impl !UnwindSafe for Expr

§

impl Freeze for Expr

§

impl Unpin for Expr

§

impl UnsafeUnpin for Expr

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.