Skip to main content

Crate elly_core

Crate elly_core 

Source
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 Bruijn index over next links 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 — an Env link, a Value::Module, an iota’s or object’s prototype — goes through it.
HostFn
A host function: a native callback provided by the embedder, behind the Rc a Value::HostFn carries.
Instances
Map from canonical name to instantiated module.
ObjectData
An object: a payload and the prototype that defines its type. A Value::Object is an Rc pointer to ObjectData.
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 __match none of whose arms matched.
Resolved
A module’s canonical name and source.
Sym
A name or symbol, interned in a realm (a Ctx). Two Syms of one realm are equal exactly when their texts are; a Sym means 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.
TraceFrame
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 val inline, or the frame that terminates the walk. The empty environment is None. Env is an Option<EnvRef>, utilizing the null-pointer niche to remain one word wide, avoiding allocation and refcount traffic when ending a chain. Lambda activations cons one Cons per bound name (zero for binder-less heads); partial application environments share the consed prefix via Rc. References are resolved to de Bruijn indices against this list’s shape.
Error
A failure at the syntax or parse stage.
FrameName
The function a call is in.
LoadError
Compile-time module loading errors.
ParseError
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).
RefutedBy
What a Refutation is by.
ReportStyle
How Ctx::report_raised shows 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§

ModuleResolver
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) in env: 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 __main body of a module instance in its own environment. Returns Ok(None) if no body is declared (e.g., a library).
instantiate
Instantiates a compiled module, the top module of chunk (see Ctx::compile_module), giving it its identity.
is_bindable_name
Whether name can 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).
HostCall
The contract a host callback signs: a whole call’s arguments — exactly arity of them, since the evaluator gathers before it fires — plus the Ctx, answering a value or a Raised.
ImportSpec
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.
ModuleName
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" (see crate::load_module).