Phantom types and subtyping

被引:13
作者
Fluet, Matthew [1 ]
Pucella, Riccardo
机构
[1] Cornell Univ, Ithaca, NY 14853 USA
[2] Northeastern Univ, Boston, MA 02115 USA
关键词
D O I
10.1017/S0956796806006046
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
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.
引用
收藏
页码:751 / 791
页数:41
相关论文
共 14 条
[1]  
[Anonymous], P ICFP ICFP 99
[2]  
BLUME M, 2001, ELECT NOTES THEORETI, V59
[3]   TYPE EXTENSION THROUGH POLYMORPHISM [J].
BURTON, FW .
ACM TRANSACTIONS ON PROGRAMMING LANGUAGES AND SYSTEMS, 1990, 12 (01) :135-138
[4]   AN EXTENSION OF SYSTEM-F WITH SUBTYPING [J].
CARDELLI, L ;
MARTINI, S ;
MITCHELL, JC ;
SCEDROV, A .
INFORMATION AND COMPUTATION, 1994, 109 (1-2) :4-56
[5]  
Damas Luis, 1982, Proceedings of the 9th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. POPL'82, P207, DOI [10.1145/582153.582176, DOI 10.1145/582153.582176]
[6]  
ELLIOTT C, 2000, WORKSH SEM APPL IMPL
[7]  
FLUET M, 2005, P ACM SIGPLAN WORKSH, P203
[8]   Domain specific embedded compilers [J].
Leijen, D ;
Meijer, E .
ACM SIGPLAN NOTICES, 2000, 35 (01) :109-122
[9]   THEORY OF TYPE POLYMORPHISM IN PROGRAMMING [J].
MILNER, R .
JOURNAL OF COMPUTER AND SYSTEM SCIENCES, 1978, 17 (03) :348-375
[10]  
Milner R., 1997, DEFINITION STANDARD