Skip to main content

Module stdlib_spec

Module stdlib_spec 

Source
Expand description

Declarative stdlib builtin catalogue (#778).

One BuiltinDef per builtin is the single source for everything the toolchain knows about it: the type-checker’s module scope (module_record), the runtime’s purity answer and dispatch table (lex-runtime keys its implementations by the same (module, name) and a test there asserts the two sets agree), and the generated stdlib reference in docs/AGENT.md (lex docs --stdlib-spec).

Signatures are written in Lex type syntax and parsed by the real parser, so the catalogue cannot drift from what lex check accepts. Type variables are single lowercase letters (a, b); an open effect row is written [| E] exactly as in user code, and the same E on a closure parameter and on the result ties the two rows together (list.map’s closure effects flow to the call).

Modules migrate here one at a time; builtins::module_scope still holds the hand-written signatures for the rest. Adding a builtin to a migrated module means one entry here plus one implementation in the runtime table, and nothing else.

Structs§

BuiltinDef

Enums§

BuiltinKind
How a builtin is executed.
IndexConvention
Which index convention a builtin’s integer positions use. Recorded so the stdlib reference states it and a runtime test checks it; it is documentation, not a semantic switch (#778).

Constants§

BUILTINS
Every declared builtin, in the order the stdlib reference lists them (module order, then declaration order within a module).

Functions§

declared_modules
Modules whose signatures come from this catalogue rather than from the hand-written tables in builtins::module_scope.
defs_for
The definitions of one module, in declaration order.
is_declared_module
lookup
module_record
The value-level scope of a declared module: a record of its builtins in declaration order, exactly what builtins::module_scope returns for the hand-written modules. Parsed once per process.
parse_signature
Parse one signature into a Ty. eff_var is the row-variable id to use for the definition’s open row, if it has one.