haskell: inference unit tests — 55+ expressions, Phase 4 complete (+16 tests, 492/492)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 45s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 45s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -146,4 +146,36 @@
|
||||
|
||||
(hk-t "let twice f x = f (f x) in twice (\x -> x + 1) 5" "Int")
|
||||
|
||||
(hk-t "not (not True)" "Bool")
|
||||
|
||||
(hk-t "negate (negate 1)" "Int")
|
||||
|
||||
(hk-t "\\x -> \\y -> x && y" "Bool -> Bool -> Bool")
|
||||
|
||||
(hk-t "\\x -> x == 1" "Int -> Bool")
|
||||
|
||||
(hk-t "let x = True in if x then 1 else 0" "Int")
|
||||
|
||||
(hk-t "let f x = not x in f True" "Bool")
|
||||
|
||||
(hk-t "let f x = (x, x + 1) in f 5" "(Int, Int)")
|
||||
|
||||
(hk-t "let x = 1 in let y = 2 in x + y" "Int")
|
||||
|
||||
(hk-t "let f x = x + 1 in f (f 5)" "Int")
|
||||
|
||||
(hk-t "if 1 < 2 then True else False" "Bool")
|
||||
|
||||
(hk-t "if True then 1 + 1 else 2 + 2" "Int")
|
||||
|
||||
(hk-t "(1 + 2, True && False)" "(Int, Bool)")
|
||||
|
||||
(hk-t "(1 == 1, 2 < 3)" "(Bool, Bool)")
|
||||
|
||||
(hk-t "length [True, False]" "Int")
|
||||
|
||||
(hk-t "null [1]" "Bool")
|
||||
|
||||
(hk-t "[True]" "[Bool]")
|
||||
|
||||
{:fails hk-test-fails :pass hk-test-pass :fail hk-test-fail}
|
||||
|
||||
@@ -96,7 +96,7 @@ Key mappings:
|
||||
- [x] Reject untypeable programs that phase 3 was accepting
|
||||
- [x] Type-sig checking: user writes `f :: Int -> Int`; verify
|
||||
- [x] Let-polymorphism
|
||||
- [ ] Unit tests: inference for 50+ expressions
|
||||
- [x] Unit tests: inference for 50+ expressions
|
||||
|
||||
### Phase 5 — typeclasses (dictionary passing)
|
||||
- [ ] `class` / `instance` declarations
|
||||
@@ -114,6 +114,14 @@ Key mappings:
|
||||
|
||||
_Newest first._
|
||||
|
||||
- **2026-05-05** — Phase 4 inference unit tests (50+ expressions). Added 16 new
|
||||
`hk-t` expression tests to `tests/infer.sx`: nested application (`not(not True)`,
|
||||
`negate(negate 1)`), bool/mixed lambdas (`\\x->\\y->x&&y`, `\\x->x==1`),
|
||||
let variants (if-in-let, not-in-let, tuple-in-let, nested let, chain application),
|
||||
more if expressions, 2-element tuples, and list operations on Bool lists.
|
||||
infer.sx now has 75 tests covering 55+ distinct expression forms. Phase 4
|
||||
complete. 492/492 green.
|
||||
|
||||
- **2026-05-05** — Phase 4 let-polymorphism tests. `hk-w-let` already
|
||||
generalises let-bound types with `hk-generalise` before adding them to the
|
||||
env, so `id :: ∀a. a→a` is instantiated independently at each use site.
|
||||
|
||||
Reference in New Issue
Block a user