Iter 15f: std_pair — 2-type-var product, no recursion
Fourth stdlib module. Pair<a, b> is the canonical product with two type vars and a single constructor MkPair. Five combinators: fst, snd, swap, map_first (Pair<a, b> -> Pair<c, b>), map_second (Pair<a, b> -> Pair<a, c>). Smallest dogfood for the parameterised-ADT path so far: no recursion in the data def or any combinator, single-arm matches throughout. Demo prints 7, 9, 9, 7, 8, 18 deterministically. No compiler bug surfaced (fourth stdlib iter in a row to land clean). The only fixable issue was a paren-balance typo in the demo's seq chain. Cumulative: 4 stdlib modules, 24 combinators. Type-system surface exercised end-to-end now spans 1/2/3-type-var data, 1/2/3-type-var fns, recursive ADTs, cross-module imports of all of the above, flat and nested patterns, TCO via monomorphised musttail, GC. Tests: 93/93 (e2e 33 → 34). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2768,3 +2768,50 @@ trees) plug in at the same desugar layer.
|
||||
**Queue update.** 16a done. Remaining: 15f (`std_pair`, optional);
|
||||
16b (local recursive `let`); 17a (per-fn arena); future
|
||||
"lit-in-Ctor" follow-up under 16c if and when needed.
|
||||
|
||||
---
|
||||
|
||||
## Iter 15f — `std_pair`: 2-type-var product, no recursion
|
||||
|
||||
**Goal.** Round out the small-ADT stdlib triad (Maybe, Either, Pair).
|
||||
Pair is the canonical product with two type vars and a single
|
||||
constructor — no recursion in the data def or any combinator.
|
||||
Smallest dogfood for the parameterised-ADT path so far.
|
||||
|
||||
**What shipped.**
|
||||
|
||||
- `examples/std_pair.ailx` (~75 LOC, 5 combinators):
|
||||
- `fst`, `snd` — projections.
|
||||
- `swap : Pair<a, b> -> Pair<b, a>`.
|
||||
- `map_first : (a -> c) -> Pair<a, b> -> Pair<c, b>`.
|
||||
- `map_second : (b -> c) -> Pair<a, b> -> Pair<a, c>`.
|
||||
Each combinator is a single-arm match on `MkPair` with no
|
||||
fall-through, so the desugar pass added in 16a is a no-op
|
||||
(the patterns are already flat).
|
||||
- `examples/std_pair_demo.ailx` exercises every combinator. Output
|
||||
(deterministic): 7, 9, 9, 7, 8, 18.
|
||||
- `crates/ail/tests/e2e.rs::std_pair_demo` guards the path.
|
||||
|
||||
**No new compiler bug surfaced.** Stdlib iter #4 in a row that
|
||||
landed clean. The only fixable issue was a paren-balance typo in
|
||||
the demo's `seq` chain, surfaced immediately by the parser's
|
||||
"unexpected end of input, expected `)`" diagnostic.
|
||||
|
||||
**Tests: 93/93** (e2e went from 33 to 34).
|
||||
|
||||
**Cumulative state, post-15f.**
|
||||
|
||||
- Stdlib: 4 modules (`std_maybe`, `std_list`, `std_either`,
|
||||
`std_pair`); 24 combinators total.
|
||||
- Type-system surface area exercised end-to-end: 1- and 2- and
|
||||
3-type-var data; 1- and 2- and 3-type-var fns; recursive ADTs;
|
||||
cross-module imports of all of the above; flat *and* nested
|
||||
patterns (16a); TCO via monomorphised `musttail`; Boehm GC.
|
||||
- Pipeline layers: `load → desugar → check → codegen → clang`.
|
||||
Each layer has a public, narrow contract; the desugar layer
|
||||
is the natural home for further surface-level smoothing
|
||||
without enlarging the core AST.
|
||||
|
||||
**Queue update.** 15f done. Remaining: 16b (local recursive `let`),
|
||||
16c (Lit-in-Ctor patterns), 17a (per-fn arena). None blocking
|
||||
further stdlib growth; each is a quality-of-life improvement.
|
||||
|
||||
Reference in New Issue
Block a user