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

@@ -41,4 +41,42 @@
;; Function body type error: applying non-function.
(hk-tc-err "reject: apply non-function" "f x = 1 x" "Int")
(define prog-sig1 (hk-core "f :: Int -> Int\nf x = x + 1"))
(define prog-sig2 (hk-core "f :: Bool -> Bool\nf x = x + 1"))
(define prog-sig3 (hk-core "id :: a -> a\nid x = x"))
(hk-test
"sig ok: Int->Int accepted"
(first (nth (hk-infer-prog prog-sig1 (hk-type-env0)) 0))
"ok")
(hk-test
"sig fail: Bool->Bool rejected"
(first (nth (hk-infer-prog prog-sig2 (hk-type-env0)) 0))
"err")
(hk-test
"sig fail: error mentions mismatch"
(hk-str-has?
(nth (nth (hk-infer-prog prog-sig2 (hk-type-env0)) 0) 1)
"mismatch")
true)
(hk-test
"sig ok: polymorphic a->a accepted"
(first (nth (hk-infer-prog prog-sig3 (hk-type-env0)) 0))
"ok")
(hk-tc-err
"run-typed sig fail: Bool declared, Int inferred"
"main :: Bool\nmain = 1 + 2"
"mismatch")
(hk-test
"run-typed sig ok: Int declared matches"
(hk-run-typed "main :: Int\nmain = 1 + 2")
3)
{:fails hk-test-fails :pass hk-test-pass :fail hk-test-fail}