Phantom types and subtyping

We investigate a technique from the literature, called the phantom-types technique, that uses parametric polymorphism, type constraints, and unification of polymorphic types to model a subtyping hierarchy. Hindley-Milner type systems, such as the one found in Standard ML, can be used to enforce the subtyping relation, at least for first-order values. We show that this technique can be used to encode any finite subtyping hierarchy (including hierarchies arising from multiple interface inheritance). We formally demonstrate the suitability of the phantom-types technique for capturing first-order subtyping by exhibiting a type-preserving translation from a simple calculus with bounded polymorphism to a calculus embodying the type system of SML.

[1]  Luca Cardelli,et al.  An Extension of System F with Subtyping , 1991, TACS.

[2]  F. Warren Burton Type extension through polymorphism , 1990, TOPL.

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

[4]  Riccardo Pucella,et al.  Practical Datatype Specializations with Phantom Types and Recursion Schemes , 2006, Electron. Notes Theor. Comput. Sci..

[5]  François Pessaux,et al.  Type-based analysis of uncaught exceptions , 2000, TOPL.

[6]  Simon L. Peyton Jones,et al.  Calling hell from heaven and heaven from hell , 1999, ICFP '99.

[7]  Walid Taha,et al.  Semantics, Applications, and Implementation of Program Generation , 2001, Lecture Notes in Computer Science.

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

[9]  Mitchell Wand,et al.  Complete Type Inference for Simple Objects , 1987, LICS.

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

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

[12]  Daan Leijen,et al.  Domain specific embedded compilers , 1999, DSL '99.

[13]  Oege de Moor,et al.  Compiling embedded languages , 2000, Journal of Functional Programming.

[14]  Jerzy Tiuryn,et al.  Type reconstruction in the presence of polymorphic recursion , 1993, TOPL.

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

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

[17]  Matthias Blume No-Longer-Foreign: Teaching an ML compiler to speak C "natively" , 2001, Electron. Notes Theor. Comput. Sci..