Files
AILang/experiments/2026-05-12-cross-model-authoring/master/examples/data_with_match.ail.json
T
Brummel a8c29d130b iter cma.1: master mini-spec + render binary for cross-model authoring experiment
New top-level experiments/2026-05-12-cross-model-authoring/ (out of
root Cargo workspace; nested-crate standalone via empty [workspace]
table per Cargo idiom). The renderer projects one canonical
master/spec.md into two form-specific files (rendered/json.md and
rendered/ailx.md) by walking three directive forms ({form-only:
json}, {form-only: ailx}, {example: <id>}) and emitting per-example
fenced blocks sourced from 13 curated .ail.json fixtures.

Four test gates green (10/10 total):
- splitter_unit (7) — directive parser, malformed inputs panic
- spec_completeness (1) — AST-variant visitor lifted verbatim from
  schema_coverage.rs; 34/34 variants covered by the curated subset
- example_roundtrip (1) — every fixture roundtrips through
  ailang_surface::{print, parse} to identical canonical bytes
- token_balance (1) — form-only block totals balanced to 3.22% under
  tiktoken-rs::cl100k_base (gate is ±5%)

Six of the 34 variants did not have a dedicated fixture topic in the
plan and were absorbed into the closest existing fixture per the
plan's Step 4.14 escape hatch (Let/Clone → fn_calls_prelude; LetRec
→ data_with_match; If → match_literal_pattern; ReuseAs →
data_simple; Const → floats). Surfaced as a journal note, not a
plan revision.

Two ancillary additions vs. plan, both structural Cargo necessities,
spec-compatible: render/Cargo.toml carries an empty [workspace] table
so the nested crate refuses parent-workspace discovery, and
render/.gitignore drops /target + Cargo.lock. Both surfaced inline
in the per-iter journal's Concerns section.

cma.2 (harness) and cma.3 (live IONOS run + DESIGN.md addendum +
journal + roadmap edits) remain out of scope per the spec.
2026-05-12 11:43:10 +02:00

119 lines
3.3 KiB
JSON

{
"schema": "ailang/v0",
"name": "data_with_match",
"imports": [],
"defs": [
{
"kind": "type",
"name": "List",
"doc": "Monomorphic singly-linked Int list — boxed, recursive.",
"ctors": [
{ "name": "Nil", "fields": [] },
{
"name": "Cons",
"fields": [
{ "k": "con", "name": "Int" },
{ "k": "con", "name": "List" }
]
}
]
},
{
"kind": "fn",
"name": "head_or_zero",
"doc": "Return the head of xs, or 0 if empty. Exercises TermMatch with two arms, PatternCtor (both nullary Nil and binary Cons), and PatternWild on the tail field.",
"type": {
"k": "fn",
"params": [ { "k": "con", "name": "List" } ],
"param_modes": ["borrow"],
"ret": { "k": "con", "name": "Int" },
"effects": []
},
"params": ["xs"],
"body": {
"t": "match",
"scrutinee": { "t": "var", "name": "xs" },
"arms": [
{
"pat": { "p": "ctor", "ctor": "Nil", "fields": [] },
"body": { "t": "lit", "lit": { "kind": "int", "value": 0 } }
},
{
"pat": {
"p": "ctor",
"ctor": "Cons",
"fields": [
{ "p": "var", "name": "h" },
{ "p": "wild" }
]
},
"body": { "t": "var", "name": "h" }
}
]
}
},
{
"kind": "fn",
"name": "count_via_letrec",
"doc": "Walk xs counting nodes using a local recursive let. Exercises TermLetRec and TermVar; the recursive `go` is bound locally.",
"type": {
"k": "fn",
"params": [ { "k": "con", "name": "List" } ],
"param_modes": ["borrow"],
"ret": { "k": "con", "name": "Int" },
"effects": []
},
"params": ["xs"],
"body": {
"t": "letrec",
"name": "go",
"type": {
"k": "fn",
"params": [ { "k": "con", "name": "List" } ],
"param_modes": ["borrow"],
"ret": { "k": "con", "name": "Int" },
"effects": []
},
"params": ["ys"],
"body": {
"t": "match",
"scrutinee": { "t": "var", "name": "ys" },
"arms": [
{
"pat": { "p": "ctor", "ctor": "Nil", "fields": [] },
"body": { "t": "lit", "lit": { "kind": "int", "value": 0 } }
},
{
"pat": {
"p": "ctor",
"ctor": "Cons",
"fields": [
{ "p": "wild" },
{ "p": "var", "name": "t" }
]
},
"body": {
"t": "app",
"fn": { "t": "var", "name": "+" },
"args": [
{ "t": "lit", "lit": { "kind": "int", "value": 1 } },
{
"t": "app",
"fn": { "t": "var", "name": "go" },
"args": [ { "t": "var", "name": "t" } ]
}
]
}
}
]
},
"in": {
"t": "app",
"fn": { "t": "var", "name": "go" },
"args": [ { "t": "var", "name": "xs" } ]
}
}
}
]
}