From 0025d3306949e145d302ee1d5503019274f11ec9 Mon Sep 17 00:00:00 2001 From: crumbtoo Date: Wed, 24 Jan 2024 10:14:44 -0700 Subject: [PATCH] stable enough for a demo hey? --- tst/Core/HindleyMilnerSpec.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tst/Core/HindleyMilnerSpec.hs b/tst/Core/HindleyMilnerSpec.hs index 7dbe178..97e4732 100644 --- a/tst/Core/HindleyMilnerSpec.hs +++ b/tst/Core/HindleyMilnerSpec.hs @@ -38,6 +38,18 @@ spec = do let e = [coreExpr|3|] in check' [] (TyCon "Bool") e `shouldSatisfy` isLeft + it "should infer `fix ((+#) 1)` :: Int" $ + let g = [ ("fix", ("a" :-> "a") :-> "a") + , ("+#", TyInt :-> TyInt :-> TyInt) ] + e = [coreExpr|fix ((+#) 1)|] + in infer' g e `shouldBe` Right TyInt + + it "should infer mutually recursively defined lists" $ + let g = [ ("cons", TyInt :-> TyCon "IntList" :-> TyCon "IntList") ] + e :: Expr' + e = [coreExpr|letrec { as = cons 1 bs; bs = cons 2 as } in as|] + in infer' g e `shouldBe` Right (TyCon "IntList") + infer' :: Context' -> Expr' -> Either [TypeError] Type infer' g e = case runErrorful $ infer g e of (Just t, _) -> Right t