Oleg has a nice article on how to implement OCaml-style type inference. It&#x27;s a more sophisticated approach than just Algorithm W: <a href="http:&#x2F;&#x2F;okmij.org&#x2F;ftp&#x2F;ML&#x2F;generalization.html" rel="nofollow">http:&#x2F;&#x2F;okmij.org&#x2F;ftp&#x2F;ML&#x2F;generalization.html</a>