Generalizing Hindley-Milner Type Inference Algorithms

Bastiaan Heeren, Jurriaan Hage, S. Doaitse Swierstra. Generalizing Hindley-Milner Type Inference Algorithms. Technical Report UU-CS-2002-031, Department of Information and Computing Sciences, Utrecht University, 2002.

Abstract

Type inferencing according to the standard algorithms W and M often yields unin- formative error messages. Many times, this is a consequence of a bias inherent in the algorithms. The method developed here is to first collect constraints from the program, and to solve these afterwards, possibly under the influence of a heuristic. We show the soundness and completeness of our algorithm. The algorithms W and M turn out to be deterministic instances of our method, giving the correctness for W and M with respect to the Hindley-Milner typing rules for free. We also show that our algorithm is more flexible, because it naturally allows the generation of multiple messages.