Abstract
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.
- Eric Allen, Jonathan Bannet, and Robert Cartwright. A first-class approach to genericity. In Proc. OOPSLA '03, pages 96--114, October 2003. Google Scholar
Digital Library
- John Altidor, Shan Shan Huang, and Yannis Smaragdakis. Taming the wildcards: Combining definition- and use-site variance. In Proc. 2011 ACM SIGPLAN Conf. on Programming Language Design and Implementation (PLDI), June 2011. Google Scholar
Digital Library
- Lennart Augustsson. Cayenne: a language with dependent types. In ACM SIGPLAN International Conf. on Functional Programming (ICFP '98), pages 239--250, 1998. Google Scholar
Digital Library
- Gavin M. Bierman, Andrew D. Gordon, Catalin Hritcu, and David Langworthy. Semantic subtyping with an SMT solver. The Journal of Functional Programming, 22(1):31--105, March 2012. Google Scholar
Digital Library
- Gilad Bracha, Martin Odersky, David Stoutamire, and Philip Wadler. Making the future safe for the past: Adding Genericity to the Java Programing Language. In Proc. OOPSLA '98, 1998. Google Scholar
Digital Library
- Nicholas Cameron and Sophia Drossopoulou. On subtyping, wildcards, and existential types. In Formal Techniques for Java-Like Programs (FTfJP), July 2009. Google Scholar
Digital Library
- Nicholas Cameron, Sophia Drossopoulou, and Erik Ernst. A model for Java with wildcards. In Proc. ECOOP '08, number 5142 in Lecture Notes in Computer Science, pages 2--26, July 2008. Google Scholar
Digital Library
- Robert Cartwright and Guy L. Steele. Compatible genericity with run-time types for the Java programming language. In Proc. OOPSLA '98, Vancouver, Canada, October 1998. Google Scholar
Digital Library
- Thierry Coquand and Gerard Huet. The Calculus of Constructions. Information and Computation, 76, 1988. Google Scholar
Digital Library
- Mark Day, Robert Gruber, Barbara Liskov, and Andrew C. Myers. Subtypes vs. Where Clauses: Constraining Parametric Polymorphism. In Proc. OOPSLA '95, pages 156--168, Austin TX, October 1995. ACM SIGPLAN Notices 30(10). Google Scholar
Digital Library
- Gilles Dubochet and Martin Odersky. Compiling structural types on the JVM: a comparison of reflective and generative techniques from Scala's perspective. In ICOOOLPS'09, pages 34--41, 2009. Google Scholar
Digital Library
- ECMA. ECMA-334: C# language specification, June 2006. http://www.ecma-international.org/publications/files/ecma-st/ECMA-334.pdf.Google Scholar
- Burak Emir, Andrew Kennedy, Claudio Russo, and Dachuan Yu. Variance and generalized constraints for C# generics. In Proc. ECOOP '06, 2006. Google Scholar
Digital Library
- Erik Ernst, Klaus Ostermann, and William R. Cook. A virtual class calculus. In 33th ACM Symp. on Principles of Programming Languages (POPL), pages 270--282, Charleston, South Carolina, January 2006. Google Scholar
Digital Library
- Cormac Flanagan. Hybrid type checking. In 33rd Annual Symposium on Principles of Programming Languages (POPL'06), pages 245--256, 2006. Google Scholar
Digital Library
- Tim Freeman and Frank Pfenning. Refinement types for ML. In Proc. 1991 ACM SIGPLAN Conf. on Programming Language Design and Implementation (PLDI), pages 268--277, June 1991. Google Scholar
Digital Library
- Vaidas Gasiunas, Mira Mezini, and Klaus Ostermann. Dependent classes. In Proc. OOPSLA '07, pages 133--152, 2007. Google Scholar
Digital Library
- J. Gosling, W. Joy, G. Steele, and G. Bracha. The Java Language Specification, Third Edition. Addison Wesley, 2006. Google Scholar
Digital Library
- Cordelia V. Hall, Kevin Hammond, Simon L. Peyton Jones, and Philip L. Wadler. Type classes in Haskell. ACM Transactions on Programming Languages and Systems (TOPLAS), 18(2):109--138, 1996. Google Scholar
Digital Library
- Atsushi Igarashi, Benjamin Pierce, and Philip Wadler. Featherweight Java: A minimal core calculus for Java and GJ. ACM Transactions on Programming Languages and Systems (TOPLAS), 23(3):396--450, 2001. Google Scholar
Digital Library
- Atsushi Igarashi and Mirko Viroli. Variant parametric types: A flexible subtyping scheme for generics. ACM Transactions on Programming Languages and Systems (TOPLAS), 28(5):795--847, 2006. Google Scholar
Digital Library
- Haskell 98: A non-strict, purely functional language. http://www.haskell.org/onlinereport/, February 1999.Google Scholar
- Andrew Kennedy and Benjamin Pierce. On decidability of nominal subtyping with variance. In Foundations of Object-Oriented Languages (FOOL), 2007.Google Scholar
- Ali Sinan Köksal, Viktor Kuncak, and Philippe Suter. Constraints as control. In 39th ACM Symp. on Principles of Programming Languages (POPL), pages 151--164, January 2012. Google Scholar
Digital Library
- Barbara Liskov et al. CLU Reference Manual. Springer-Verlag, 1984. Google Scholar
Digital Library
- Howard Lovatt. Simplyfing Java generics by eliminating wildcards, January 2008. Retrieved March 22, 2009.Google Scholar
- O. Lehrmann Madsen, B. Møller-Pedersen, and K. Nygaard. Object Oriented Programming in the BETA Programming Language. Addison-Wesley, June 1993. Google Scholar
Digital Library
- Ole Lehrmann Madsen and Birger Møller-Pedersen. Virtual classes: A powerful mechanism for object-oriented programming. In Proc. OOPSLA '89, pages 397--406, October 1989. Google Scholar
Digital Library
- Michael J. Maher. Complete axiomatizations of the algebras of finite, rational and infinite trees. In Third Annual Symposium on Logic in Computer Science, 1988.Google Scholar
Cross Ref
- Donna Malayeri and Jonathan Aldrich. Integrating nominal and structural subtyping. In Proc. ECOOP '08, number 5142 in Lecture Notes in Computer Science, July 2008. Google Scholar
Digital Library
- Per Martin-Löf. A Theory of Types. 1971.Google Scholar
- Conor McBride and James McKinna. The view from the left. Journal of Functional Programming, 14(1):69--111, 2004. Google Scholar
Digital Library
- Todd Millstein. Practical predicate dispatch. In Proc. OOPSLA '04, October 2004. Google Scholar
Digital Library
- John C. Mitchell. Coercion and type inference. In 11th Annual ACM Symposium on Principles of Programming Languages (POPL'84), pages 174--185, 1984. Google Scholar
Digital Library
- Andrew C. Myers, Joseph A. Bank, and Barbara Liskov. Parameterized types for Java. In 24th ACM Symp. on Principles of Programming Languages (POPL), pages 132--145, Paris, France, January 1997. Google Scholar
Digital Library
- Karl A. Nyberg, editor. The annotated Ada reference manual. Grebyn Corporation, Vienna, VA, USA, 1989. Google Scholar
Digital Library
- Nathaniel Nystrom, Vijay Saraswat, Jens Palsberg, and Christian Grothoff. Constrained types for object-oriented languages. In Proc. OOPSLA '08, October 2008. Google Scholar
Digital Library
- Martin Odersky. Report on the programming language Scala. Technical report, EPFL, 2006.Google Scholar
- John C. Reynolds. Three approaches to type structure. In TAPSOFT/CAAP 1985, volume 185 of Lecture Notes in Computer Science, pages 97--138. Springer-Verlag, 1985. Google Scholar
Digital Library
- Patrick Rondon, Ming Kawaguchi, and Ranjit Jhala. Liquid types. In Proc. 2008 ACM SIGPLAN Conf. on Programming Language Design and Implementation (PLDI), June 2008. Google Scholar
Digital Library
- Martin Sulzmann, Martin Odersky, and Martin Wehr. Type inference with constrained types. In Fourth International Workshop on Foundations of Object-Oriented Programming (FOOL 4), 1997.Google Scholar
- Alexander J. Summers. Modelling Java requires state. In Formal Techniques for Java-Like Programs (FTfJP), July 2009. Google Scholar
Digital Library
- Alexander J. Summers, Nicholas Cameron, Mariangiola Dezani-Ciancaglini, and Sophia Drossopoulou. Towards a semantic model for java wildcards. In Formal Techniques for Java-Like Programs (FTfJP), June 2010. Google Scholar
Digital Library
- Kresten Krab Thorup. Genericity in Java with virtual types. In Proc. ECOOP '97, number 1241 in Lecture Notes in Computer Science, pages 444--471, 1997.Google Scholar
Cross Ref
- Kresten Krab Thorup and Mads Torgersen. Unifying genericity: Combining virtual types and parameterized classes. In Proc. ECOOP '98, 1998.Google Scholar
- Mads Torgersen, Christian Plesner Hansen, Erik Ernst, Peter von der Ahé, Gilad Bracha, and Neal Gafter. Adding wildcards to the Java programming language. In SAC, March 2004. Google Scholar
Digital Library
- Mirko Viroli. A type-passing approach for the implementation of parametric methods in Java. The Computer Journal, 46(3):263--294, 2003.Google Scholar
Cross Ref
- Mirko Viroli and Antonio Natali. Parametric polymorphism in Java: an approach to translation based on reflective features. In Proc. OOPSLA '00, pages 146--165, 2000. Google Scholar
Digital Library
- Hongwei Xi and Frank Pfenning. Dependent types in practical programming. In 26th Annual ACM Symposium on Principles of Programming Languages (POPL'99), pages 214--227, San Antonio, TX, January 1999. Google Scholar
Digital Library
Index Terms
Constrained kinds
Recommendations
Constrained kinds
OOPSLA '12: Proceedings of the ACM international conference on Object oriented programming systems languages and applicationsModern 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 ...
Generalized algebraic data types and object-oriented programming
OOPSLA '05: Proceedings of the 20th annual ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applicationsGeneralized algebraic data types (GADTs) have received much attention recently in the functional programming community. They generalize the (type) parameterized algebraic datatypes (PADTs) of ML and Haskell by permitting value constructors to return ...
Generalized algebraic data types and object-oriented programming
Proceedings of the 20th annual ACM SIGPLAN conference on Object oriented programming systems languages and applicationsGeneralized algebraic data types (GADTs) have received much attention recently in the functional programming community. They generalize the (type) parameterized algebraic datatypes (PADTs) of ML and Haskell by permitting value constructors to return ...







Comments