haskell: type-sig checking — hk-ast-type + hk-check-sig + sig-aware infer-prog (+6 tests, 470/470)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 39s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-05 23:02:34 +00:00
parent 2606b83920
commit d8f3f8c3b2
3 changed files with 124 additions and 12 deletions

View File

@@ -94,7 +94,7 @@ Key mappings:
- [x] Algorithm W: unification + type schemes + generalisation + instantiation
- [x] Report type errors with meaningful positions
- [x] Reject untypeable programs that phase 3 was accepting
- [ ] Type-sig checking: user writes `f :: Int -> Int`; verify
- [x] Type-sig checking: user writes `f :: Int -> Int`; verify
- [ ] Let-polymorphism
- [ ] Unit tests: inference for 50+ expressions
@@ -114,6 +114,17 @@ Key mappings:
_Newest first._
- **2026-05-05** — Phase 4 type-sig checking. `hk-ast-type` converts parsed type
AST nodes (`t-con`/`t-var`/`t-fun`/`t-app`/`t-list`/`t-tuple`) to internal
type values. `hk-collect-tvars` gathers free type variable names. `hk-check-sig`
wraps declared type in a scheme (if polymorphic), instantiates with fresh vars,
and unifies against the inferred type. `hk-infer-prog` updated: first pass
collects `type-sig` declarations into a `sigs` dict; second pass checks each
successful fun-clause inference against its declared sig, returning
`("err" "... declared type mismatch: ...")` on mismatch. 6 new tests in
`typecheck.sx` cover monomorphic sig match, sig mismatch (error message),
polymorphic `a->a` sig, and `hk-run-typed` with and without sig. 470/470 green.
- **2026-05-05** — Phase 4 reject untypeable programs. `hk-typecheck` runs
`hk-infer-prog` on a program AST and raises the first type error found.
`hk-run-typed` is a drop-in for `hk-run` that gates evaluation on a