Pragmatic subtyping in polymorphic languages

We present a subtyping extension to the Hindley/Milner type system that is based on name inequivalence. This approach allows the subtype relation to be defined by incremental construction of polymorphic records and datatypes, in a way that subsumes the basic type systems of both languages like ML and Java. As the main contribution of the paper, we describe a partial type inference algorithm for the extended system which favours succinctness over generality, in the sense that it never infers types with subtype constraints. The algorithm is based on an efficient approximating constraint solver, and is able to type a wide range of programs that utilize subtyping and polymorphism in a non-trivial way. Since constrained types are not inferred, the algorithm cannot be complete; however, we provide a completeness result w.r.t. the Hindley/Milner type system as a form of characterizing lower bound.

[1]  Robin Milner,et al.  Definition of standard ML , 1990 .

[2]  Benjamin C. Pierce,et al.  Local type inference , 1998, POPL '98.

[3]  John C. Mitchell,et al.  Lower bounds on type inference with subtypes , 1995, POPL '95.

[4]  John C. Mitchell,et al.  Type Inference with Extended Pattern Matching and Subtypes , 1993, Fundamenta Informaticae.

[5]  Luca Cardelli,et al.  On Binary Methods , 1995, Theory Pract. Object Syst..

[6]  OderskyMartin,et al.  Polymorphic type inference and abstract data types , 1994 .

[7]  Didier Rémy,et al.  Objective ML: a simple object-oriented extension of ML , 1997, POPL '97.

[8]  Prateek Mishra,et al.  Polymorphic Subtype Inference: Closing the Theory-Practice Gap , 1989, TAPSOFT, Vol.2.

[9]  Geoffrey Smith,et al.  Principal Type Schemes for Functional Programs with Overloading and Subtyping , 1994, Sci. Comput. Program..

[10]  Stefan Kaes Type inference in the presence of overloading, subtyping and recursive types , 1992, LFP '92.

[11]  Scott F. Smith,et al.  Subtyping Constrained Types , 1996, SAS.

[12]  John H. Reppy,et al.  Simple objects for Standard ML , 1996, PLDI '96.

[13]  Ryan Stansifer,et al.  Type inference with subtypes , 1988, POPL '88.

[14]  Guy L. Steele,et al.  The Java Language Specification , 1996 .

[15]  Mark P. Jones,et al.  Using parameterized signatures to express modular structure , 1996, POPL '96.

[16]  Philip Wadler,et al.  A practical subtyping system for Erlang , 1997, ICFP '97.

[17]  Alberto Martelli,et al.  An Efficient Unification Algorithm , 1982, TOPL.

[18]  John C. Mitchell,et al.  Type inference with simple subtypes , 1991, Journal of Functional Programming.

[19]  Luca Cardelli An implementation of F , 1993 .

[20]  Mark P. Jones A system of constructor classes: overloading and implicit higher-order polymorphism , 1993, FPCA '93.

[21]  Mark P. Jones,et al.  First-class polymorphism with type inference , 1997, POPL '97.

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

[23]  Luca Cardelli,et al.  On understanding types, data abstraction, and polymorphism , 1985, CSUR.

[24]  Magnus Carlsson,et al.  Reactive objects in a functional language : an escape from the Evil I , 1997, ICFP 1997.

[25]  Frank Pfenning,et al.  Refinement types for ML , 1991, PLDI '91.

[26]  Martin Odersky,et al.  Polymorphic type inference and abstract data types , 1994, TOPL.

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

[28]  Jakob Rehof Minimal typings in atomic subtyping , 1997, POPL '97.

[29]  John C. Mitchell,et al.  Coercion and type inference , 1984, POPL.

[30]  Scott F. Smith,et al.  Sound polymorphic type inference for objects , 1995, OOPSLA.