haskell: Phase 14 — record desugar (con-rec → con-def + accessor fun-clauses)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 57s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 57s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -249,7 +249,7 @@ No OCaml changes are needed. The view type is fully representable as an SX dict.
|
||||
|
||||
- [x] Parser: extend `hk-parse-data` to recognise `{ field :: Type, … }`
|
||||
constructor bodies. AST node: `(:con-rec CNAME [(FNAME TYPE) …])`.
|
||||
- [ ] Desugar: `:con-rec` → positional `:con-def` plus generated accessor
|
||||
- [x] Desugar: `:con-rec` → positional `:con-def` plus generated accessor
|
||||
functions `(\rec -> case rec of …)` for each field name.
|
||||
- [ ] Record creation `Foo { bar = 1, baz = "x" }` parsed as
|
||||
`(:rec-create CON [(FNAME EXPR) …])`. Eval builds the same tagged list as
|
||||
@@ -313,6 +313,18 @@ No OCaml changes are needed. The view type is fully representable as an SX dict.
|
||||
|
||||
_Newest first._
|
||||
|
||||
**2026-05-07** — Phase 14 record desugar (`:con-rec` → positional + accessors):
|
||||
- New `hk-record-accessors` helper in `desugar.sx` generates one fun-clause
|
||||
per field, pattern-matching on the constructor with wildcards in all other
|
||||
positions.
|
||||
- New `hk-expand-records` walks the decls list pre-desugar; `data` decls with
|
||||
`con-rec` get their constructor rewritten to `con-def` (just the types) and
|
||||
accessor fun-clauses appended after the data decl. Other decls pass through.
|
||||
- Wired into the `program` and `module` cases of `hk-desugar`. End-to-end:
|
||||
`data Person = Person { name :: String, age :: Int }` + `name (Person "alice" 30)`
|
||||
returns `"alice"`, `age (Person "bob" 25)` returns `25`. No regressions in
|
||||
parse / desugar / deriving.
|
||||
|
||||
**2026-05-07** — Phase 14 record parser: `data Foo = Foo { name :: T, … }`:
|
||||
- Extended `hk-parse-con-def` to peek for `{` after the constructor name; if
|
||||
found, parse `varid :: type` pairs separated by commas, terminate with `}`,
|
||||
|
||||
Reference in New Issue
Block a user