Simple Type Inference for Structural Polymorphism

We propose a new way to mix constrained types and type inference, where the interaction between the two is minimal. By using local constraints embedded in types, rather than the other way round, we obtain a system which keeps the usual structure of an Hindley-Milner type system. In practice, this means that it is easy to introduce local constraints in existing type inference algorithms. Eventhough our system is notably weaker than general constraintbased type systems, making it unable to handle subtyping for instance, it is powerful enough to accomodate many features, from simple polymorphic records a la Ohori to Objective Caml’s polymorphic variants, and accurate typing of pattern matching (i.e. polymorphic message dispatch), all these through tiny variations in the constraint part of the system.

[1]  Jacques Garrigue,et al.  A Label-Selective Lambda-Calculus with Optional Arguments and its Compilation Method , 1995 .

[2]  Didier Rémy,et al.  Extending ML with Semi-Explicit Higher-Order Polymorphism , 1997, TACS.

[3]  P. Hudak,et al.  A general framework for hindley/milner type systems with constraints , 2000 .

[4]  Peter Buneman,et al.  Theoretical Aspects of Object-Oriented Programming , 1994 .

[5]  Gert Smolka,et al.  A Feature-Based Constraint System for Logic Programming with Entailment , 1992, FGCS.

[6]  Didier Rémy,et al.  Type checking records and variants in a natural extension of ML , 1989, POPL '89.

[7]  Robin Milner,et al.  Principal type-schemes for functional programs , 1982, POPL '82.

[8]  Andrew Kennedy,et al.  Dimension Types , 1994, ESOP.

[9]  Martin Müller,et al.  Type Inference for First-Class Messages with Feature Constraints , 2000, Int. J. Found. Comput. Sci..

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

[11]  Jacques Garrigue,et al.  The typed polymorphic label-selective λ-calculus , 1994, POPL '94.

[12]  Atsushi Ohori,et al.  A polymorphic record calculus and its compilation , 1995, TOPL.

[13]  Didier Rémy,et al.  Type inference for records in natural extension of ML , 1994 .

[14]  Matthias Felleisen,et al.  A Syntactic Approach to Type Soundness , 1994, Inf. Comput..

[15]  Gert Smolka,et al.  A Feature Constraint System for Logic Programming with Entailment , 1994, Theor. Comput. Sci..

[16]  Susumu Nishimura,et al.  Static typing for dynamic messages , 1998, POPL '98.

[17]  Alexander Aiken,et al.  Soft typing with conditional types , 1994, POPL '94.

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

[19]  Mitchell Wand,et al.  Type inference for record concatenation and multiple inheritance , 1989, [1989] Proceedings. Fourth Annual Symposium on Logic in Computer Science.

[20]  François Pottier,et al.  A Versatile Constraint-Based Type Inference System , 2000, Nord. J. Comput..