A Generalization of Hybrid Let-Polymorphic Type Inference Algorithms

We present a generalized let-polymorphic type inference algorithm, prove that any of its instances is sound and complete with respect to the Hindley/Milner let-polymorphic type system, and find a condition on two instance algorithms so that one algorithm should find type errors earlier than the other. By instantiating the generalized algorithm with different parameters, we can achieve not only the two opposite algorithms (the bottom-up standard algorithm W and the top-down algorithm M) but also other hybrid algorithms which are used in real compilers. Such instances’ soundness and completeness follow automatically, and their relative earliness in detecting type-errors are determined by checking a simple condition. The set of instances of the generalized algorithm is a superset of those used in the two most popular ML compilers: SML/NJ and OCaml.

[1]  Martin Odersky,et al.  Type Inference with Constrained Types , 1999, Theory Pract. Object Syst..

[2]  Damien Doligez,et al.  The Objective Caml system release 2.04 , 2002 .

[3]  Mitchell Wand Finding the source of type errors , 1986, POPL '86.

[4]  Bruce James McAdam On the unification of substitutions in type inference , 1999 .

[5]  Robin Milner,et al.  A Theory of Type Polymorphism in Programming , 1978, J. Comput. Syst. Sci..

[6]  Bruce J. McAdam Generalising Techniques for Type Debugging , 1999, Scottish Functional Programming Workshop.

[7]  Alexander Aiken,et al.  Type inclusion constraints and type inference , 1993, FPCA '93.

[8]  Michael Maher Diagnosing Non-Well-Moded Concurrent Logic Programs , 1996 .

[9]  Satish R. Thatte,et al.  Type Inference with Partial Types , 1988, Theor. Comput. Sci..

[10]  Laurence Rideau,et al.  Interactive Programming Environment for ML , 1997 .

[11]  Eugene W. Stark,et al.  Debugging Type Errors (Full version) , 1995 .

[12]  Martin Sulzmann,et al.  Hindley/Milner style type systems in constraint form , 1999 .

[13]  Fritz Henglein,et al.  Type inference with polymorphic recursion , 1993, TOPL.

[14]  Ryan Stansifer,et al.  Explaining type errors in polymorphic languages , 1993, LOPL.

[15]  Kwangkeun Yi,et al.  A Generalized Let-Polymorphic Type Inference Algorithm , 2000 .

[16]  Martin Sulzmann A General Type Inference Framework for Hindley/Milner Style Systems , 2001, FLOPS.

[17]  Jun Yang Explaining Type Errors by Finding the Source of a Type Conflict , 1999, Scottish Functional Programming Workshop.

[18]  Kwangkeun Yi,et al.  Proofs about a folklore let-polymorphic type inference algorithm , 1998, TOPL.

[19]  Dominic Duggan,et al.  Explaining Type Inference , 1996, Sci. Comput. Program..