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 a code chunk of flat code which a tree-walking evaluator
then runs. Both run in a realm, a Ctx: the code a realm parses is
evaluated and rendered in that realm.
let ctx = elly_core::Ctx::new();
let code = ctx.parse("(&x x) .foo").unwrap();
assert_eq!(ctx.eval(code).unwrap().to_display(&ctx), ".foo");Re-exports§
pub use code::ChunkId;pub use code::HomeLeaf;pub use code::Text;pub use source::ChunkLoc;pub use source::ChunkSpan;pub use source::CtxSpan;pub use source::Doc;pub use source::DocSource;pub use source::Len;pub use source::Line;pub use source::Loc;pub use source::Location;pub use source::Pos;
Modules§
- code
- Code in static chunks: the flat form of one compile (see
docs/done/2026-10-11_elly-ctx-chunks.md). - source
- Source locations (see
docs/done/2026-10-11_elly-ctx-chunks.md, Source locations).
Structs§
- Ctx
- The long-lived state of an evaluation, the equivalent of a JS realm: the
unique-id source for closure identities, the builtin module cache, the
environment free list, and the module loader — a resolver plus the cache of
modules loaded through it (
load). - 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 (Node::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. - Instances
- Map from canonical name to instantiated module.
- Object
Data - An object: a payload and the prototype that defines its type.
A
Value::Objectis anRcpointer toObjectData. - Refutation
- What refuted a value: the parameter or binding pattern a refutation
escaped, with its whole value, however deep inside it the refuting
pattern was; or a case or a
__matchnone of whose arms matched. - Resolved
- A module’s canonical name and source.
- Sym
- A name or symbol, interned in a realm (a
Ctx). TwoSyms of one realm are equal exactly when their texts are; aSymmeans nothing in another realm, except a fixed one, which every realm shares. - Trace
- What an error unwound through on its way to the top: see
Ctx::take_trace. - Trace
Frame - A call an error unwound through.
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.
- Frame
Name - The function a call is in.
- 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.
- Raised
- Value unwinding through the single error channel (see
docs/elly-spec.md). - Refuted
By - What a
Refutationis by. - Report
Style - How
Ctx::report_raisedshows each place in a trace. - TyKind
- Value kinds with builtin module prototypes, allowing
as <Proto>to compile to a discriminant test (see [Pat::TypeKind]). - Value
- A runtime value.
Traits§
- Module
Resolver - Host-provided module loader. Maps an import spec to its canonical name and source.
Functions§
- apply_
with - Apply a value to a single argument in the realm
ctx— the public entry point behind a host’s “call this value” surface (e.g. the Python bindings’elly.Fun.__call__). - eval_
env - Runs an expression chunk (see
Ctx::parse) inenv: its top module’s body, with no module terminal around it. 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, the top module of
chunk(seeCtx::compile_module), giving it its identity. - 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_
fresh - Parse Elly source into a new realm, for a caller that has none: tests, benches and one-off tools. Returns the realm with the code, since the code is evaluated and rendered in it.
Type Aliases§
- DocText
- A document as a host shows it: its name, and its text if the host has
it (see
Ctx::report_raised). - 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).