In the process of implementing my own compiler, I found an inconsistency between the implementation of type inference between the poly and poly_constraints compilers in chapter 7.
I believe it has to do with the constraint generation around the "let" construct. In particular, let polymorphism doesn't seem to behave consistently.
A simple term that exhibits the problem is
let f = let add = \a b -> a + b in add
"poly" reports the type of "f" as "int -> int -> int," as it should be
"poly_constraints" reports it has type "forall a b c. a -> b -> c", which is too general.
In the process of implementing my own compiler, I found an inconsistency between the implementation of type inference between the poly and poly_constraints compilers in chapter 7.
I believe it has to do with the constraint generation around the "let" construct. In particular, let polymorphism doesn't seem to behave consistently.
A simple term that exhibits the problem is
"poly" reports the type of "f" as "int -> int -> int," as it should be
"poly_constraints" reports it has type "forall a b c. a -> b -> c", which is too general.