Map: core / prelude
core/src/prelude.ral is the standard library, written in ral and baked into the
binary at build time. build.rs reads it once, scanning its top-level let
bindings into PRELUDE_EXPORTS and the ## summary above each into
PRELUDE_DOCS — the table help and explain print from
(builtins), since only values and schemes survive the
bake — and the consumer build scripts serialise the annotated
IR — typechecked by the same bake_prelude path the runtime uses,
typecheck — as a postcard blob (the schema hazard
documented in core/src/lib.rs). It
is evaluated once per bake, on a core-only shell, and its bindings are seated
whole in every shell by BakedPrelude::seat: a prelude that fails to run
panics rather than seating a partial one.
The prelude holds the library-level surface: higher-order list and string
combinators (for, reduce, take-while, drop-while, take, drop,
enumerate, flat-map, zip, cross, nub, group-by, median-by,
words, from-words, indent, repeat, pad-left, pad-right,
extension, max, min, maximum, minimum, map-lines, commands (an audit
report’s `command facts, in trail order), succeeded (an audit
report’s outcome as a Bool), …) layered over the directly-registered Rust
builtins (each, map, filter, fold, …), and the structured fan-out
over the gather and spawn control operators: par (a bounded parallel
map that keeps input order in bytes and values), both and first-of, beside
is-done (gather). These are ordinary
values of fixed arity (fixed-arity).
Structural equality is the == / != expression operator; callbacks use
ordinary lambdas such as { |a b| $[$a == $b] }.
The branching and exception forms if, case, and try are not prelude
bindings — they are IR primitives (CompKind::If / Case / Try, see
ir) introduced by elaboration, alongside
the seven reserved control operators. The prelude
adds the iteration and collection vocabulary on top of that primitive core.
docs/SPEC.md §14 lists the prelude exports; a command name’s head is classified once
at the surface (Head in core/src/syntax/ast.rs, syntax).