iter 22b.4a: journal entry

This commit is contained in:
2026-05-09 22:30:17 +02:00
parent 0709e319ab
commit 692899867b
+105
View File
@@ -11603,3 +11603,108 @@ Prelude declares `Show`, `Eq`, `Ord` over `Int`, `Bool`, `Str`
through `Show.show`, Form-B class/instance prose lands, round-trip
filter retires. End-to-end gate: any prior `print 42`-style fixture
must keep working through `Show.show#Int`.
## 2026-05-09 — Iteration 22b.4a: Form-A parser+printer arms for ClassDef/InstanceDef (and forall-constraints gap fix)
Closes the round-trip gap that 22b.1 deliberately deferred: every
`examples/*.ail.json` fixture now round-trips through
`parse(print(M))` with canonical-equal JSON, including the
`test_22b1_*`, `test_22b2_*`, `test_22b3_*` typeclass fixtures that
the skip-list excluded. 106 fixtures green (up from 70). Bench gates
all 0/0/0.
**Per-task subjects (mirror commit messages):**
- 22b.4a.1: form-a parser arm for ClassDef
- 22b.4a.2: form-a parser arm for InstanceDef
- 22b.4a.3: form-a printer arm for ClassDef
- 22b.4a.4: form-a printer arm for InstanceDef
- 22b.4a.4.5: form-a printer+parser arms for Type::Forall constraints (gap fix)
- 22b.4a.5: retire round-trip skip-list for class/instance fixtures
- 22b.4a.6: spec + DESIGN amendments — 22b.4 split, terminology fix, '__' separator, forall-constraints gap
**S-expression form locked:**
ClassDef:
(class <Name>
(param <ident>)
[(superclass (class <Name>) (type <ident>))]
[(doc "...")]
(method <name> (type <fn-type>) [(default <body>)])*)
InstanceDef:
(instance
(class <Name>)
(type <type-expr>)
[(doc "...")]
(method <name> (body <term>))*)
Type::Forall constraints (extension to existing forall-type form):
(forall (vars …)
[(constraints (constraint <Class> <type>)+)]
<body>)
**Iteration split rationale:** the brainstorm-original 22b.4 bundled
surface arms with the Prelude module + `int_to_str` C-runtime
primitive + end-to-end `show 42` fixture. Surface arms touch one
crate with no runtime risk; the Prelude work touches `runtime/`,
`ailang-codegen`, `ailang-check::builtins`, plus codegen wiring for
the new primitive. Different review surface, different risk profile,
different bench-gate exposure. The split (22b.4a / 22b.4b) is
recorded in the spec amendments section and is the substantive
follow-up for 22b.4b.
**Terminology fix:** the original spec called the surface arms
"Form-B parser/printer arms". `crates/ailang-surface` is in fact
**Form-A** (parseable s-expression); `crates/ailang-prose` is Form-B
(one-way prose, no parser by design). The 22b.1 round-trip-skip-list
comment carried the same conflation. Both corrected in the spec
amendment.
**Mid-iter gap fix:** Task 5's pre-flight surfaced that the existing
Form-A arms dropped `Type::Forall.constraints` (the field added in
22b.2). Four `test_22b2_*` fixtures regressed when the filter was
lifted. Fixed inline via 22b.4a.4.5 by extending `parse_forall_type`
and the `Type::Forall` arm of `write_type` to round-trip the
constraints clause. The skip-list had silently masked this gap
alongside the ClassDef/InstanceDef gap; retiring it required closing
both in the same iter.
**Quality-review carry-overs:**
- Strict duplicate-clause detection in the new parser arms
(`(param ...)`, `(superclass ...)`, `(doc ...)`, `(method (type
...))`, `(method (body ...))`) — sibling parsers (`parse_fn`,
`parse_data`, `parse_const`) silently overwrite earlier clauses
with later ones. The new strict pattern is correct; the silent
pattern is the wart. Promoting siblings to the strict pattern is
out of scope for 22b.4a (it would expand to all existing fixtures
and require their own RED tests). Filed as known debt.
- `pos: 0` fallback in missing-required-clause errors — pre-existing
pattern across all def parsers; mirroring it in the new code
preserves consistency. Targeted fix would be cross-crate and
belongs in a separate iter.
**Known debt (deferred to 22b.4b or later):**
- Form-B (prose) printer arms for ClassDef / InstanceDef. One-way,
not gating; queued for the audit cycle or 22b.4b cleanup.
- DESIGN.md line 1749 ("the exact textual form is fixed in 22b
alongside the existing mangling scheme") still does not name
`__` directly. The load-bearing rationale was added at line 1607
(the `show__Int` example paragraph); line 1749 is a forward
reference whose update is audit-cycle work.
- Strict duplicate-clause detection in `parse_fn` / `parse_data`
/ `parse_const` — file as known asymmetry, do not retrofit in
22b.4a.
**Bench gates:** all three (`bench/check.py`, `bench/compile_check.py`,
`bench/cross_lang.py`) exited 0/0/0 (matches 22b.3 close).
**Next iter (queued):** 22b.4b — Prelude module with `class Show
a where show : (a borrow) -> Str`, `instance Show Int`, the
`int_to_str` C-runtime primitive, codegen wiring, and an end-to-end
`show 42` fixture printing `42` through the mono pass.