My journey studying type inference in Haskell.
You can find here an implementation of a very simple type inferer for the following:
- Lambda abstractions
-
+
,-
,*
,/
,==
,>=
,<=
,>
and<
operators -
if
andcase
expressions -
let
expressions
This: parseExpr "\\x.\\y.x+y"
Will give you this: Right (Lam "x" (Lam "y" (App (App (Var "+") (Var "x")) (Var "y"))))
This: typeOf "\\x.\\y.x+y"
Will give you this: Int->Int->Int