C# in Depth

Cover of C# in Depth
Order now (3rd edition)

Hindley-Milner type inference

Chapter 9: Lambda expressions and expression trees: 9.4.3

Created: 3/4/2008
Last updated: 3/4/2008

I won't pretend to fully understand this comment, as I hadn't heard of Hindley-Milner type inference (Wikipedia link) before, other than it being briefly mentioned in Eric's blog:

A number of people have asked me why we didn’t simply use Hindley-Milner type inference, a la F#, OCAML, etc. Two reasons.
  1. HM type inference is not guaranteed to terminate in a reasonable amount of time; our type inference algorithm guarantees progress every time through the loop and therefore runs in polynomial time. (Though of course, overload resolution can then be exponential in C#, which is unfortunate.)
  2. HM type inference works poorly in a language which has class inheritance; it was designed for functional languages like Haskell with pattern matching rather than inheritance.