ML 2007 START Conference Manager    

Efficient ML Type Inference using Ranked Type Variables

George Kuan and David MacQueen

The 2007 ACM SIGPLAN Workshop on ML (ML 2007)
Freiburg, Germany, October 5, 2007


Abstract

The Damas-Milner type inference algorithm (commonly known as algorithm W) is at the core of all ML type checkers. Although the algorithm is known to have poor worst-case behavior, in practice well-engineered type checkers will run in approximately linear time. To achieve this efficiency, implementations need to improve on algorithm W's method of scanning the complete type environment to determine whether a type variable can be generalized at a let binding. Following a suggestion of Damas's, most ML type checkers use an alternative method based on ranking unification variables to track their position in the type environment.

Here we formalize two such ranking systems, one based on lambda depth (used in the SML/NJ compiler), and the other based on let depth (used in OCaml, for instance). Each of these systems is formalized both with and without the value restriction, and they are proved correct relative to the classic algorithm W. Our formalizations of the various algorithms use simple abstract machines that are similar to small-step evaluation semantics.


  
START Conference Manager (V2.54.4)
Maintainer: rrgerber@softconf.com