Constrained kinds

Modern object-oriented languages such as X10 require a rich framework for types capable of expressing both value-dependency and genericity, and supporting pluggable, domain-specific extensions. In earlier work, we presented a framework for constrained types in object-oriented languages, parametrized by an underlying constraint system. Types are viewed as formulas C{c} where C is the name of a class or an interface and c is a constraint on the immutable instance state (the properties) of C. Constraint systems are a very expressive framework for partial information. Many (value-)dependent type systems for object-oriented languages can be viewed as constrained types. This paper extends the constrained types approach to handle type-dependency ("genericity"). The key idea is to introduce constrained kinds: in the same way that constraints on values can be used to define constrained types, constraints on types can define constrained kinds. We develop a core programming language with constrained kinds. Generic types are supported by introducing type variables---literally, variables with "type" Type---and permitting programs to impose subtyping and equality constraints on such variables. We formalize the type-checking rules and establish soundness. While the language now intertwines constraints on types and values, its type system remains parametric in the choice of the value constraint system (language and solver). We demonstrate that constrained kinds are expressive and practical and sketch possible extensions with a discussion of the design and implementation of X10.

[1]  Sophia Drossopoulou,et al.  On subtyping, wildcards, and existential types , 2009, FTfJP@ECOOP.

[2]  Alexander J. Summers Modelling Java requires state , 2009, FTfJP@ECOOP.

[3]  Robert Cartwright,et al.  A first-class approach to genericity , 2003, OOPSLA 2003.

[4]  Gilad Bracha,et al.  Adding wildcards to the Java programming language , 2004, SAC '04.

[5]  Andrew C. Myers,et al.  Parameterized types for Java , 1997, POPL '97.

[6]  Mirko Viroli,et al.  Parametric polymorphism in Java: an approach to translation based on reflective features , 2000, OOPSLA '00.

[7]  Kresten Krab Thorup Genericity in Java with Virtual Types , 1997, ECOOP.

[8]  Frank Pfenning,et al.  Dependent types in practical programming , 1999, POPL '99.

[9]  Cormac Flanagan,et al.  Hybrid type checking , 2006, POPL '06.

[10]  Martin Odersky,et al.  Compiling structural types on the JVM: a comparison of reflective and generative techniques from Scala's perspective , 2009, ICOOOLPS@ECOOP.

[11]  Simon L. Peyton Jones,et al.  Type classes in Haskell , 1994, TOPL.

[12]  Andrew D. Gordon,et al.  Semantic subtyping with an SMT solver , 2010, ICFP '10.

[13]  Philip Wadler,et al.  Featherweight Java: a minimal core calculus for Java and GJ , 2001, TOPL.

[14]  Lennart Augustsson,et al.  Cayenne—a language with dependent types , 1998, ICFP '98.

[15]  Ole Lehrmann Madsen,et al.  Virtual classes: a powerful mechanism in object-oriented programming , 1989, OOPSLA '89.

[16]  P. Medawar A view from the left , 1984, Nature.

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

[18]  Patrick Maxim Rondon,et al.  Liquid types , 2008, PLDI '08.

[19]  Mira Mezini,et al.  Dependent classes , 2007, OOPSLA.

[20]  Robert Cartwright,et al.  Compatible genericity with run-time types for the Java programming language , 1998, OOPSLA '98.

[21]  Sophia Drossopoulou,et al.  A Model for Java with Wildcards , 2008, ECOOP.

[22]  Dachuan Yu,et al.  Variance and Generalized Constraints for C# Generics , 2006, ECOOP.

[23]  Thierry Coquand,et al.  The Calculus of Constructions , 1988, Inf. Comput..

[24]  Ralf Hinze,et al.  Haskell 98 — A Non−strict‚ Purely Functional Language , 1999 .

[25]  Mirko Viroli,et al.  A Type-Passing Approach for the Implementation of Parametric Methods in Java , 2003, Comput. J..

[26]  Craig Schaffert,et al.  CLU Reference Manual , 1984, Lecture Notes in Computer Science.

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

[28]  Andrew C. Myers,et al.  Subtypes vs. where clauses: constraining parametric polymorphism , 1995, OOPSLA.

[29]  Ole Lehrmann Madsen,et al.  Object-oriented programming in the BETA programming language , 1993 .

[30]  Michael J. Maher Complete axiomatizations of the algebras of finite, rational and infinite trees , 1988, [1988] Proceedings. Third Annual Information Symposium on Logic in Computer Science.

[31]  Viktor Kuncak,et al.  Constraints as control , 2012, POPL '12.

[32]  John C. Reynolds,et al.  Three Approaches to Type Structure , 1985, TAPSOFT, Vol.1.

[33]  Todd D. Millstein,et al.  Practical predicate dispatch , 2004, OOPSLA.

[34]  Peter H. Golde,et al.  C# Language Specification , 2003 .

[35]  Shan Shan Huang,et al.  Taming the wildcards: combining definition- and use-site variance , 2011, PLDI '11.

[36]  Jonathan Aldrich,et al.  Integrating Nominal and Structural Subtyping , 2008, ECOOP.

[37]  Martin Odersky,et al.  Making the future safe for the past: adding genericity to the Java programming language , 1998, OOPSLA '98.

[38]  James Gosling,et al.  The Java Language Specification, 3rd Edition , 2005 .

[39]  Karl A. Nyberg The annotated Ada reference manual , 1989 .

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

[41]  William R. Cook,et al.  A virtual class calculus , 2006, POPL '06.

[42]  Jens Palsberg,et al.  Constrained types for object-oriented languages , 2008, OOPSLA.

[43]  A. W. Hofmann The Theory of Types , 1964 .

[44]  Peter Müller,et al.  Formal Techniques for Java-Like Programs (FTfJP) , 2004, ECOOP Workshops.

[45]  Mads Torgersen,et al.  Unifying Genericity - Combining the Benefits of Virtual Types and Parameterized Classes , 1999, ECOOP.

[46]  Mirko Viroli,et al.  Variant parametric types: A flexible subtyping scheme for generics , 2006, ACM Trans. Program. Lang. Syst..

[47]  Sophia Drossopoulou,et al.  Towards a semantic model for Java wildcards , 2010, FTfJP@ECOOP.

[48]  B. Pierce,et al.  On Decidability of Nominal Subtyping with Variance , 2006 .