haskell: Phase 14 — record creation Foo { f = e, … } (parser + desugar)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m0s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m0s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -251,7 +251,7 @@ No OCaml changes are needed. The view type is fully representable as an SX dict.
|
||||
constructor bodies. AST node: `(:con-rec CNAME [(FNAME TYPE) …])`.
|
||||
- [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
|
||||
- [x] Record creation `Foo { bar = 1, baz = "x" }` parsed as
|
||||
`(:rec-create CON [(FNAME EXPR) …])`. Eval builds the same tagged list as
|
||||
positional construction (field order from the data decl).
|
||||
- [ ] Record update `r { field = v }` parsed as `(:rec-update EXPR [(FNAME EXPR)])`.
|
||||
@@ -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-creation syntax `Foo { f = e, … }`:
|
||||
- Parser: post-`conid` peek for `{` triggers `hk-parse-rec-create`, returning
|
||||
`(:rec-create cname [(fname expr) …])`.
|
||||
- `hk-record-fields` dict (in desugar.sx — load order requires it live there)
|
||||
is populated by `hk-expand-records` when it sees a `con-rec`.
|
||||
- New `:rec-create` case in `hk-desugar` looks up the field order, builds an
|
||||
`app` chain `(:app (:app (:con cname) e1) e2 …)` in declared order. Field-
|
||||
pair lookup via new `hk-find-rec-pair` helper. Order in source doesn't
|
||||
matter — `Person { age = 99, name = "bob" }` correctly produces a Person
|
||||
with name="bob", age=99 regardless of source order.
|
||||
- Verified via direct execution; no regressions in parse/desugar/deriving.
|
||||
|
||||
**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
|
||||
|
||||
Reference in New Issue
Block a user