skip to main content
research-article

Constrained kinds

Published:19 October 2012Publication History
Skip Abstract Section

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.

References

  1. Eric Allen, Jonathan Bannet, and Robert Cartwright. A first-class approach to genericity. In Proc. OOPSLA '03, pages 96--114, October 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. Lennart Augustsson. Cayenne: a language with dependent types. In ACM SIGPLAN International Conf. on Functional Programming (ICFP '98), pages 239--250, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  5. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  6. Nicholas Cameron and Sophia Drossopoulou. On subtyping, wildcards, and existential types. In Formal Techniques for Java-Like Programs (FTfJP), July 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. Thierry Coquand and Gerard Huet. The Calculus of Constructions. Information and Computation, 76, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  11. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  12. ECMA. ECMA-334: C# language specification, June 2006. http://www.ecma-international.org/publications/files/ecma-st/ECMA-334.pdf.Google ScholarGoogle Scholar
  13. Burak Emir, Andrew Kennedy, Claudio Russo, and Dachuan Yu. Variance and generalized constraints for C# generics. In Proc. ECOOP '06, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. Cormac Flanagan. Hybrid type checking. In 33rd Annual Symposium on Principles of Programming Languages (POPL'06), pages 245--256, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. Vaidas Gasiunas, Mira Mezini, and Klaus Ostermann. Dependent classes. In Proc. OOPSLA '07, pages 133--152, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. J. Gosling, W. Joy, G. Steele, and G. Bracha. The Java Language Specification, Third Edition. Addison Wesley, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  20. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  21. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  22. Haskell 98: A non-strict, purely functional language. http://www.haskell.org/onlinereport/, February 1999.Google ScholarGoogle Scholar
  23. Andrew Kennedy and Benjamin Pierce. On decidability of nominal subtyping with variance. In Foundations of Object-Oriented Languages (FOOL), 2007.Google ScholarGoogle Scholar
  24. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  25. Barbara Liskov et al. CLU Reference Manual. Springer-Verlag, 1984. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Howard Lovatt. Simplyfing Java generics by eliminating wildcards, January 2008. Retrieved March 22, 2009.Google ScholarGoogle Scholar
  27. O. Lehrmann Madsen, B. Møller-Pedersen, and K. Nygaard. Object Oriented Programming in the BETA Programming Language. Addison-Wesley, June 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  29. 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 ScholarGoogle ScholarCross RefCross Ref
  30. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  31. Per Martin-Löf. A Theory of Types. 1971.Google ScholarGoogle Scholar
  32. Conor McBride and James McKinna. The view from the left. Journal of Functional Programming, 14(1):69--111, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Todd Millstein. Practical predicate dispatch. In Proc. OOPSLA '04, October 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. John C. Mitchell. Coercion and type inference. In 11th Annual ACM Symposium on Principles of Programming Languages (POPL'84), pages 174--185, 1984. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  36. Karl A. Nyberg, editor. The annotated Ada reference manual. Grebyn Corporation, Vienna, VA, USA, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Nathaniel Nystrom, Vijay Saraswat, Jens Palsberg, and Christian Grothoff. Constrained types for object-oriented languages. In Proc. OOPSLA '08, October 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Martin Odersky. Report on the programming language Scala. Technical report, EPFL, 2006.Google ScholarGoogle Scholar
  39. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  40. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  41. 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 ScholarGoogle Scholar
  42. Alexander J. Summers. Modelling Java requires state. In Formal Techniques for Java-Like Programs (FTfJP), July 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  44. 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 ScholarGoogle ScholarCross RefCross Ref
  45. Kresten Krab Thorup and Mads Torgersen. Unifying genericity: Combining virtual types and parameterized classes. In Proc. ECOOP '98, 1998.Google ScholarGoogle Scholar
  46. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  47. Mirko Viroli. A type-passing approach for the implementation of parametric methods in Java. The Computer Journal, 46(3):263--294, 2003.Google ScholarGoogle ScholarCross RefCross Ref
  48. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  49. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Constrained kinds

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        • Published in

          cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 47, Issue 10
          OOPSLA '12
          October 2012
          1011 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/2398857
          Issue’s Table of Contents
          • cover image ACM Conferences
            OOPSLA '12: Proceedings of the ACM international conference on Object oriented programming systems languages and applications
            October 2012
            1052 pages
            ISBN:9781450315616
            DOI:10.1145/2384616

          Copyright © 2012 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 19 October 2012

          Check for updates

          Qualifiers

          • research-article

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!