haskell: Phase 13 — where-clauses in instance bodies (desugar fix, +4 tests)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 50s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-07 12:18:21 +00:00
parent 5605fe1cc2
commit c821e21f94
3 changed files with 67 additions and 58 deletions

View File

@@ -220,7 +220,7 @@ No OCaml changes are needed. The view type is fully representable as an SX dict.
### Phase 13 — `where` in typeclass instances + default methods
- [ ] Verify `where`-clauses in `instance` bodies desugar correctly. The
- [x] Verify `where`-clauses in `instance` bodies desugar correctly. The
`hk-bind-decls!` instance arm must call the same where-lifting logic as
top-level function clauses. Write a targeted test to confirm.
- [ ] Class declarations may include default method implementations. Parser:
@@ -307,6 +307,18 @@ No OCaml changes are needed. The view type is fully representable as an SX dict.
_Newest first._
**2026-05-07** — Phase 13 `where`-clauses in `instance` bodies:
- Bug discovered: `hk-desugar` didn't recurse into `instance-decl` method
bodies, so a `where`-form in an instance method survived to eval and hit
`eval: unknown node tag 'where'`. Fix: added an `instance-decl` case to
the desugarer that maps `hk-desugar` over the method-decls list. The
existing `fun-clause` branch then desugars each method body, including
the where → let lifting.
- 4 tests in new `tests/instance-where.sx`: where-helper with literal
pattern matching, references reused multiple times, and multi-binding
where. Verified no regression in class.sx (14/14), deriving.sx (15/15),
desugar.sx (15/15).
**2026-05-07** — Phase 12 conformance: uniquewords.hs (4/4) + setops.hs (8/8) → Phase 12 complete:
- `program-uniquewords.sx`: `foldl Set.insert` over a word list, then check
`Set.size`/`member`. 4/4.