haskell: Phase 13 — class default method registration + dispatch fallback
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m4s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m4s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -223,10 +223,10 @@ No OCaml changes are needed. The view type is fully representable as an SX dict.
|
||||
- [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:
|
||||
- [x] Class declarations may include default method implementations. Parser:
|
||||
`hk-parse-class` collects method decls; eval registers defaults under
|
||||
`"__default__ClassName_method"` in the class dict.
|
||||
- [ ] Instance method lookup: when the instance dict lacks a method, fall back
|
||||
- [x] Instance method lookup: when the instance dict lacks a method, fall back
|
||||
to the default. Wire this into the dictionary-passing dispatch.
|
||||
- [ ] `Eq` default: `(/=) x y = not (x == y)`. Verify it works without an
|
||||
explicit `/=` in every Eq instance.
|
||||
@@ -307,6 +307,16 @@ No OCaml changes are needed. The view type is fully representable as an SX dict.
|
||||
|
||||
_Newest first._
|
||||
|
||||
**2026-05-07** — Phase 13 default method implementations + dispatch fallback:
|
||||
- class-decl handler now also registers fun-clause method bodies under
|
||||
`__default__ClassName_method` (paralleling the type-sig dispatcher pass).
|
||||
- Dispatcher rewritten as nested `if`s: instance dict has the method →
|
||||
use it; else look up default → use it; else raise. Earlier attempt with
|
||||
`cond + and` infinite-looped — switched to plain `if` form which works.
|
||||
- Both regular dispatch (`describe x = "a boolean"` instance) and default
|
||||
fallback (`hello x = "hi"` default with empty instance body) verified.
|
||||
No regressions in class/deriving/instance-where/eval suites.
|
||||
|
||||
**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
|
||||
|
||||
Reference in New Issue
Block a user