Hindley Milner is awesome and surpursingly not super hard to implement. Shameless plug: Wrote a minimal implementation in OCaml back in college https://github.com/prakhar1989/type-inference
But also thanks to that detour, this article is a nice read on OCaml in particular: http://okmij.org/ftp/ML/generalization.html
I had to rewrite mine (https://github.com/chewxy/hm) twice, and finally removing typeclasses to be fast enough for a inference system I wrote.