resources for learning Hindley-Milner type inference for undergraduate students

Petr Pudlak wrote:
could somebody recommend me study materials for learning Hindley-Milner type inference algorithm I could recommend to undergraduate students?
Perhaps you might like a two-lecture course for undergraduates, which uses Haskell throughout http://okmij.org/ftp/Haskell/AlgorithmsH.html#teval It explained HM type inference in a slightly different way, strongly emphasizing type inference as a non-standard interpretation. The second main idea was relating polymorphism and `inlining' (copying). Type schemas were then introduced as an optimization, to inlining. It becomes clear why it is unsound to infer a polymorphic type for ref []: expressions of polymorphic types are always inlined (conceptually, at least), which goes against the dynamic semantics of reference cells. The lectures also show how to infer not only the type but also the type environment. This inference helps to make the point that `tests' cannot replace typing. We can type check open expressions (and infer the minimal environment they make sense to use in). We cannot run (that is, dynamically check) open expressions.
participants (1)
-
oleg@okmij.org