I\'m currently learning OCaml, and I\'m curious to HOW OCaml does its type inferencing. I know that it\'s done through a process called unification, and I tried reading abou
The canonical reference for learning about HM type inference in ML would probably be Ben Pierce's "Types and Programming Languages." You can find the topic covered in chapter 22 of that book.
The first instance of the type inference algorithm is known as Algorithm W.
However, it may surprise you to know that -- in fact -- OCaml's implementation does not simply generate the constraints and solve them! In fact, it does a much more efficient graph based algorithm for type inference which (while speedy) leads to occasionally strange type errors being reported. You can look to references on explaining type errors in ML.