Expand description
Elly — a small language layered on Muon (see docs/elly-spec.md).
This crate implements a subset including references, application, & abstraction,
symbols, and positional lists with projection. It uses the muon crate for
syntax, parsing into an Expr which is then evaluated by a tree-walking
evaluator.
let expr = elly_core::parse("(&x x) .foo").unwrap();
assert_eq!(elly_core::eval(&expr).unwrap().to_display(), ".foo");Structs§
- Ctx
- Evaluation context threaded through the tree-walker: includes the unique-id
source for closure identities and the builtin module cache. It does not hold
a module registry or loader; imports are resolved before evaluation
(
crate::load_module), and loaded modules areRc-held values. - Env
- A shared, persistent environment: a nameless cons list of the running
activation’s bindings (innermost first) on top of the closure’s captured
Frame. A resolved reference (Expr::Local) reaches its value by walking its de Bruijnindexovernextlinks and cloning the cell’s value — a pointer chase without name comparison or per-link cloning. Indices beyond the consed cells land in the frame array. The resolver (resolve.rs) assigns each reference the exact number of cells between it and its binder. - EnvRef
- A shared reference to an
EnvNode: every handle on a node — anEnvlink, aValue::Module, an iota’s or object’s prototype — goes through it. - HostFn
- A host function: a native callback provided by the embedder, behind the
RcaValue::HostFncarries. - Import
Decl - One
importdeclaration: the name the importing module reaches the instance by, and the spec its host resolver is handed. - Instances
- Map from canonical name to instantiated module.
- Module
Data - A loaded module containing an immutable, name-sorted table of unevaluated
item bodies. Built by
crate::compile_moduleand stored in anRc. Sibling references are compiled toExpr::ModItemand resolved via the home module in the environment (crate::eval_env::EnvNode::Module), ensuring the value heap remains acyclic. Seedocs/done/2026-08-07_elly-modules-v0.md. - Object
Data - An object: a payload and the prototype that defines its type.
A
Value::Objectis anRcpointer toObjectData. - Resolved
- A module’s canonical name and source.
Enums§
- Builtin
- A native builtin operation in the reserved
__namespace. All are curried. - EnvNode
- One link of the environment list: a single binding carrying its
valinline, or the frame that terminates the walk. The empty environment isNone.Envis anOption<EnvRef>, utilizing the null-pointer niche to remain one word wide, avoiding allocation and refcount traffic when ending a chain. Lambda activations cons oneConsper bound name (zero for binder-less heads); partial application environments share the consed prefix viaRc. References are resolved to de Bruijn indices against this list’s shape. - Error
- A failure at the syntax or parse stage.
- Expr
- An Elly expression for the initial subset. Strings and records are deferred per the spec.
- Home
Leaf - Home-module leaf types: the module itself (
Self), construction (#Self(…)), or payload read (x.Self). These share the same resolution machinery (one walk to the terminal) and differ only in their eval result. - Load
Error - Compile-time module loading errors.
- Parse
Error - A parse failure: the input is a valid Muon tree but not a well-formed Elly program in this subset.
- Pattern
- A pattern: the left-hand side of a binding (
&<pat> …,let (<pat> = …), or a__matchclause). Matched by the evaluator’s native matcher (match_patternineval.rs).Bind/Discardare irrefutable. - Proto
Ref - Prototype used in
as <Proto>patterns. - Raised
- Value unwinding through the single error channel (see
docs/elly-spec.md). - TyKind
- Value kinds with builtin module prototypes, allowing
as <Proto>to compile to a discriminant test (seeProtoRef::Kind). - Value
- A runtime value.
Traits§
- Module
Resolver - Host-provided module loader. Maps an import spec to its canonical name and source.
Functions§
- apply
- Apply a value to a single argument — the public entry point behind a host’s
“call this value” surface (e.g. the Python bindings’
elly.Fun.__call__). - apply_
with - Applies a value to a single argument using a caller-supplied
Ctx. This ensures identities minted by the call continue the provided context’s ID source rather than restarting at zero. Required for hosts that manage callables across multipleapplycalls to avoid ID collisions. - compile_
module - Compile Elly module source into
ModuleData. - compile_
module_ framed - Compile Elly module source against a frame of ordered names.
- compile_
module_ named - Same as
compile_module_framed, but records the canonical source name used by__Mod.nameand for instance deduplication. - eval
- Evaluate an expression in the empty environment.
- eval_
env - Evaluates an expression in a given environment and context.
Public entry point for host evaluation (e.g.,
elly.Env.eval). - eval_
main - Evaluates the
__mainbody of a module instance in its own environment. ReturnsOk(None)if no body is declared (e.g., a library). - instantiate
- Instantiates a compiled module, creating its
Moduleterminal and returning it as aValue::Module. - is_
bindable_ name - Whether
namecan be bound and referenced from source as a plain name. - load_
module - Loads a module and its import graph: resolves, compiles, and instantiates
modules leaves-first, returning the instance for
spec. - load_
module_ source - Loads a module from provided source under
name. - parse
- Parse Elly source into an
Exprwith name resolution. Free variables causeParseError::UnboundName. - parse_
module - Parse a module source’s top-level sequence into its declarations.
- parse_
open - Parse Elly source into an
Exprwithout resolution (open term). Used by tooling and the parse golden suite. For evaluation, preferparse. - parse_
preluded - Parse Elly source into an
Exprresolved against a fixed outer frame (prelude). Unknown names causeParseError::UnboundName. - parse_
program - Parse a program (single top-level chain) to an expression.
- resolve
- Resolve a program against an empty scope; free names are rejected as
ParseError::UnboundName. Rewritesexprin place (names → de Bruijn locals). - resolve_
module_ bodies - Resolve a module’s bodies in place. Item names are sorted to provide a stable index space for order-independent mutual recursion.
- resolve_
open - Resolve an open term: free names are auto-bound below the whole scope.
- resolve_
prelude - Resolve
expragainst a named outerprelude. References toprelude[i]become indexiof the root frame.
Type Aliases§
- Host
Call - The contract a host callback signs: a whole call’s arguments — exactly
arityof them, since the evaluator gathers before it fires — plus theCtx, answering a value or aRaised. - Import
Spec - What a module’s source writes to name an import — a path, a package-qualified name. Its grammar belongs to the host resolver, not to Elly.
- Module
Name - What a resolver answers a spec with: one name per module, however many specs
reach it. Module instances are deduplicated by this name, so a resolver that
returns the spec unchanged would hand back two instances of one module for
"./foo"and"foo"(seecrate::load_module). - Text
- An owned, cheap-clone text leaf using hipstr’s
Local(Rc) backend. Short strings (≤ 23 bytes on 64-bit) are inlined; longer strings use a sharedRc<str>slice. This ensuresExprandValueare'staticand independent of the Muon source. Host tags are stored via [Text::from_static].