Skip to content

v0.8.0

Choose a tag to compare

@github-actions github-actions released this 24 Jun 15:57
· 966 commits to main since this release
1996e18

Added

  • Monomorphic type system — total static type checking. Every Wavelet
    expression now has a WIT type, decided by a static checker pass (src/check.rs)
    that runs on every path — wavelet run, wavelet build, wavelet wit,
    and the playground — before any code runs or any component is emitted. Checking
    is total: an ill-typed definition is a compile error even when nothing calls
    it, so type errors surface at build/run/wit time rather than at the wasm
    boundary. Inference is bidirectional — types propagate inward from contexts
    (function signatures, Let bindings, Match results) and synthesize outward
    from atoms and applications.
  • Numeric-literal resolution + defaulting, and The ascription. A bare
    numeric literal takes its type from context and is range-checked against it
    (The u8 300 is a compile error); with no context it defaults to s64
    (integers) or f64 (fractionals). The The form ascribes a type to an
    expression (The s64 5), both to pin a literal and to drive resolution where
    arguments alone don't decide.
  • Ad-hoc overloading. Several monomorphic Defs sharing a name form an
    overload set. Each call site is resolved statically: first by the WIT types
    of its arguments, then — when arguments don't decide — by the expected return
    type supplied via The. An exported overload set is name-mangled at the
    component boundary
    so each concrete instance gets a distinct WIT export
    (e.g. an eq over point is exported as eq-point).
  • Derive {Eq Ord Show Hash} t. Derives the standard operations for a type,
    expanding to concrete monomorphic definitions (e.g. eq-point, show-point)
    whose WIT signatures are synthesized like any other export.
  • Functor instantiation via Import {pkg: … elem: t as: …}. A parameterized
    import specializes a generic interface to a concrete element type, synthesizing
    a per-element WIT interface (e.g. set instantiated at point yields a
    concrete point-set interface) — nothing generic survives into the emitted
    world.
  • Macro components — run macros defined in other components. Import {pkg: "…" macros: true} imports a macro library: a component exporting
    wavelet:meta/macros@0.1.0 (manifest() → (name, arity) pairs, expand(name, args) → result<tree, string>). Wavelet instantiates it at compile time,
    registers its macro arities with the reader (so foreign TitleCase macros read
    paren-free, top-to-bottom, like local DefMacros), and routes expansion
    through the component's expand to a fixpoint (design.md §6.2–§6.3). The
    library's .wasm is resolved from an explicit from: path or the conventional
    wit/macros/<ns>-<name>.wasm location. A macros: true import is
    compile-time-only: it is excluded from the synthesized runtime world, so the
    shipped component never imports wavelet:meta/macros. Because a macro library
    is an ordinary component, macros can be written in any language that compiles to
    one, and they run sandboxed by construction.
  • Qualified and aliased foreign macros. Imported macros are available both
    bare (Element) and qualified by the import alias (dsl/Element, with
    as:). A bare TitleCase name provided by two imports — or by an import and a
    local DefMacro — is ambiguous and errors only when used bare, with a
    message suggesting you alias or qualify; the qualified spelling always
    resolves.
  • Build-time component runtime. Running foreign macros at compile time needs
    a wasm runtime, so the compiler now depends on wasmtime (native targets
    only). It is gated out of the wasm32 build: the browser-playground bindings
    moved behind a new default-on playground cargo feature, so the
    wasm-compiled interpreter (and the macro-library guest) build without
    wasmtime or wasm-bindgen. The playground therefore has no component
    runtime — foreign-macro examples run only in native wavelet build, not in
    the browser.
  • Produce macro components from Wavelet (wavelet build). A .wvl file
    whose top level is a Package declaration plus DefMacros only (no Export,
    no runtime defs) now compiles into a component exporting wavelet:meta/macros,
    so a macro library can be written in Wavelet itself and imported with
    Import {… macros: true} like any other macro component (design.md §6.3). Each
    macro body is compiled to wasm (the compiler learned to emit
    Quote/Quasi/Unquote/Splice, gensym, and the form-introspection
    builtins), so the produced component carries no interpreter and is built
    in-process — no cargo, no wasm32-unknown-unknown target. The interpreter
    remains the differential oracle the compiled expansions are checked against.

Changed

  • Macro expansion is compiled, not interpreted (native build). A file's
    local DefMacros and produced macro libraries now expand through a compiled
    wavelet:meta/macros component rather than the tree-walking interpreter, so
    wavelet build/wavelet expand no longer interpret macros. Macro builds are
    faster and need no wasm32-unknown-unknown target. The browser playground
    keeps expanding local macros with the in-browser interpreter (it has no
    component runtime); the interpreter also stays as the differential oracle.

Fixed

  • The type checker now runs on wavelet run, wavelet build, and
    wavelet wit, not only the playground.
    Previously the checker (and, on the
    run path, overload resolution) was wired into the playground evaluator alone:
    wavelet run bound same-named Defs by last-wins shadowing — so an overloaded
    call reached whichever def was read last and failed or silently ran the wrong
    body — and wavelet build/wavelet wit emitted/synthesized ill-typed programs
    without complaint. Each of these paths now type-checks the (expanded, for
    build/wit) program first, so an ill-typed program is rejected everywhere and an
    overloaded call dispatched through wavelet run resolves to the correct member.
  • Compiled add/sub/mul/div/rem/neg and lt/le/gt/ge now
    match the interpreter on floats and strings.
    The wasm backend previously
    unboxed every operand as an integer, so a compiled component that did f64
    arithmetic or compared strings built cleanly but trapped at runtime. These
    builtins now dispatch on the operand at runtime: arithmetic does f64 math
    when an operand is a decimal (widening integers in mixed operands), and the
    comparisons order strings lexicographically and numbers as f64 — the same
    results the interpreter (the semantics oracle) produces.
  • Compiled arithmetic is strictly binary. add/sub/mul/div/rem in a
    compiled component now require exactly two arguments, as the interpreter
    already did, instead of silently folding three or more.
  • Compiled integer overflow is checked. add/sub/mul overflow and the
    div/rem edge cases (divide-by-zero, INT_MIN / -1, INT_MIN % -1) now
    trap in a compiled component, matching the interpreter's checked-arithmetic
    errors instead of wrapping.
  • -inf is matched as a whole word. The lexer no longer splits a longer
    token beginning with -inf (e.g. -info, -infinity) into -inf plus a
    trailing fragment, mirroring the whole-word match the positive inf/nan
    literals already used.
  • wavelet run reports a missing entry point. Running a file with no
    no-argument run closure now prints an actionable error instead of silently
    doing nothing.
  • u64 parameters reject negatives. The interpreter's dynamic type check for
    a u64 parameter now rejects negative integers, consistent with the to-u64
    builtin.
  • Overload name-mangling at the WIT boundary is no longer over-broad and emits
    legal WIT.
    Exporting an ordinary library-named function defined once (e.g.
    get, head, map, concat, to-string) is no longer treated as a
    one-member overload set and name-mangled; only a genuine ≥2-member overload set
    or one of the curated overloadable operations (the derivable eq/compare/
    show/hash and the comparison/arithmetic operators) triggers mangling. The
    mangled suffix is also now an identifier-safe WIT label: a constructor-typed
    first parameter such as list(s32) produces eq-list-s32 rather than the
    illegal eq-list<s32>.
  • Overload mangling no longer collides on members that differ only past the
    first parameter.
    The mangled WIT label was derived from the first parameter
    type alone, so two members like eq {a: point b: string} and
    eq {a: point b: s32} both became eq-point — two functions of the same name
    in one interface (invalid WIT). When the first-parameter labels are all
    distinct they are kept unchanged (so eq over point/string stays
    eq-point/eq-string); when any collide, the whole set is disambiguated over
    all parameter types (eq-point-string, eq-point-s32). A genuine duplicate
    (two members with identical parameter type lists) is now a clear compile error
    naming the export instead of emitting invalid WIT.
  • A Derived op's auto-export no longer collides with an explicit
    re-export.
    Derive auto-emits a bare Export {op}-{t} for each derived
    operation, so writing that same Export eq-point yourself (a derived op is an
    ordinary exportable function) declared it twice and synthesized a duplicate
    eq-point WIT function. Identical export declarations — same exported name and
    same explicit signature — are now collapsed to one before WIT synthesis;
    declarations that share a name but differ in interface or signature are kept.
  • An ordinary Import carrying an elem: field is no longer hijacked as a
    functor.
    Functor instantiation is now classified by the import's package
    identity, not by the presence of an elem: field: only an Import whose pkg:
    is a known functor package (currently wavelet:coll/set) is read as a functor.
    Any other import that merely happens to use elem: (e.g.
    Import {pkg: "acme:widget/thing" elem: point as: w}) stays an ordinary import
    with the unknown field ignored, instead of erroring with unknown functor package. A known functor package missing its elem: is still a clear error.
  • wavelet wit now expands macros before synthesizing the world. The wit
    subcommand synthesized straight from the read forms without running expansion,
    so Derive (and any foreign macro) never ran on the wit path: a program that
    wavelet build compiles failed under wavelet wit with e.g. Export eq-point has no definition. wavelet wit now runs the same foreign-macro-aware expand
    pipeline as wavelet build/wavelet expand, so the two subcommands agree about
    the same source.
  • An exported overload set now builds to a component. wavelet wit
    synthesized a mangled WIT export per overload member (eq-point,
    eq-string, …) and the interpreter resolved the set, but wavelet build
    failed with export eq-point has no Def Fn: the emitter keyed its internal
    functions by the members' shared original name (eq), which collapses
    last-wins, so the export wrappers — which look bodies up by the mangled name
    — found nothing. The emitter now records the exact (params, body) each
    mangled export was synthesized from and emits one concrete internal function
    per member keyed on that identity, so a single curated-op overload export
    (Def eq Fn {a: point b: point} true + Export eq) and a genuine multi-member
    overload set both componentize.

What's Changed

  • feat: run macros defined in other components by @logaan in #12
  • docs: plan for replacing the interpreter with the compiler by @logaan in #14
  • Compile macros to wasm (strategy A → B): replace-interpreter Step 1 by @logaan in #16
  • docs: compiler implementation review (review.todo.typ) by @logaan in #13
  • docs: design doc for Wavelet's monomorphic, WIT-bounded type system by @logaan in #18
  • Fix compiler-review findings: backend numeric parity + robustness nits by @logaan in #17
  • test(type-system): TDD plan for the monomorphic type system by @logaan in #19
  • feat(type-system): implement the monomorphic type system (Steps 1–12) by @logaan in #20
  • release 0.8.0 by @logaan in #21

Full Changelog: v0.7.0...v0.8.0