Files
AILang/examples/lit_pat.ail
T
Brummel 72e54f4fd3 iter ext-rename: .ailx → .ail across the live toolchain
The surface-form file extension changes from .ailx to .ail. AILang's
authoring surface now uses the same .ail stem as its canonical JSON
form (.ail.json), giving the language a single coherent extension
family: .ail is the LLM-authored Form A, .ail.json is the canonical
JSON-AST Form B.

Scope (touched):
- 61 example renames examples/**/*.ailx → .ail (git mv)
- 1 rename experiments/.../rendered/ailx.md → ail.md
- 35 content-edited live-toolchain files (crates/, docs/DESIGN.md,
  docs/roadmap.md, docs/PROSE_ROUNDTRIP.md, skills/, bench/reference/*.c,
  experiment crates under experiments/.../{render,harness,master})
- Experiment-crate cohort rename Cohort::Ailx → Cohort::Ail,
  Form::Ailx → Form::Ail, per_cohort/ailx → per_cohort/ail,
  {form-only: ailx} → {form-only: ail}, ```ailx → ```ail

Out of scope (deliberately untouched, to preserve honest history):
- docs/journal-archive.md (content-frozen per CLAUDE.md)
- docs/journals/, docs/specs/, docs/plans/, bench/orchestrator-stats/
- experiments/.../runs/ (frozen LLM-output artefacts; models actually
  saw .ailx — renaming would falsify the experimental record)

Verification: cargo build/test --workspace green; experiment crate
cargo test green; bench/check.py + compile_check.py + cross_lang.py
all 0-regressed; negative grep for ailx|Ailx|AILX outside the
out-of-scope paths returns zero matches.

Opens immediate follow-up: roadmap.md P2 todo `ail check`/build/run
accept .ail extension — after this rename, .ail is canonical
authoring surface but the CLI still produces a misleading JSON-parse
error on `ail check foo.ail`. That's the next iter.
2026-05-12 14:20:27 +02:00

55 lines
2.1 KiB
Plaintext

; Iter 16c — lit patterns at top level and inside Ctor sub-patterns.
; `classify` matches an Int against three lit arms (0, 1, default).
; `categorize_first` matches a List<Int>: empty -> -1, head==0 -> 0,
; otherwise the head value. The latter exercises Pat-Lit nested
; inside Pat-Ctor's first field. Both shapes are now handled by the
; 16c desugar pass; codegen sees only If/Match-on-Ctor combinations.
;
; Iter 16d update — the chain machinery's terminator is now the
; polymorphic `__unreachable__` builtin (`forall a. a`, lowered to
; LLVM `unreachable`) instead of a `Unit` literal. That removed the
; pre-16d need for a trailing `(case _ 0)` arm in `categorize_first`
; whose only purpose was to dominate the synthetic `Unit`-typed
; terminator. The two ctor arms (`Nil` and `Cons h _`) are
; exhaustive on `IntList`; the chain default is never reached.
;
; Expected stdout (one per line): 100, 200, 999, -1, 0, 7.
(module lit_pat
(data IntList
(ctor Nil)
(ctor Cons (con Int) (con IntList)))
(fn classify
(doc "Map 0->100, 1->200, anything else->999.")
(type (fn-type (params (con Int)) (ret (con Int))))
(params n)
(body
(match n
(case (pat-lit 0) 100)
(case (pat-lit 1) 200)
(case _ 999))))
(fn categorize_first
(doc "Empty -> -1; first element 0 -> 0; otherwise return the head.")
(type (fn-type (params (con IntList)) (ret (con Int))))
(params xs)
(body
(match xs
(case (pat-ctor Nil) -1)
(case (pat-ctor Cons (pat-lit 0) _) 0)
(case (pat-ctor Cons h _) h))))
(fn main
(doc "Drive both fns. Expected (per line): 100, 200, 999, -1, 0, 7.")
(type (fn-type (params) (ret (con Unit)) (effects IO)))
(params)
(body
(seq (do io/print_int (app classify 0))
(seq (do io/print_int (app classify 1))
(seq (do io/print_int (app classify 17))
(seq (do io/print_int (app categorize_first (term-ctor IntList Nil)))
(seq (do io/print_int (app categorize_first (term-ctor IntList Cons 0 (term-ctor IntList Nil))))
(do io/print_int (app categorize_first (term-ctor IntList Cons 7 (term-ctor IntList Nil))))))))))))