skip to main content
research-article

Elaborating intersection and union types

Authors Info & Claims
Published:09 September 2012Publication History
Skip Abstract Section

Abstract

Designing and implementing typed programming languages is hard. Every new type system feature requires extending the metatheory and implementation, which are often complicated and fragile. To ease this process, we would like to provide general mechanisms that subsume many different features.

In modern type systems, parametric polymorphism is fundamental, but intersection polymorphism has gained little traction in programming languages. Most practical intersection type systems have supported only refinement intersections, which increase the expressiveness of types (more precise properties can be checked) without altering the expressiveness of terms; refinement intersections can simply be erased during compilation. In contrast, unrestricted intersections increase the expressiveness of terms, and can be used to encode diverse language features, promising an economy of both theory and implementation.

We describe a foundation for compiling unrestricted intersection and union types: an elaboration type system that generates ordinary λ-calculus terms. The key feature is a Forsythe-like merge construct. With this construct, not all reductions of the source program preserve types; however, we prove that ordinary call-by-value evaluation of the elaborated program corresponds to a type-preserving evaluation of the source program.

We also describe a prototype implementation and applications of unrestricted intersections and unions: records, operator overloading, and simulating dynamic typing.

Skip Supplemental Material Section

Supplemental Material

References

  1. Alexander Aiken, Edward L. Wimmers, and T. K. Lakshman. Soft typing with conditional types. In Principles of Programming Languages, pages 163--173, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Franco Barbanera, Mariangiola Dezani-Ciancaglini, and Ugo de'Liguoro. Intersection and union types: syntax and semantics. Information and Computation, 119: 202--230, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Robert Cartwright and Mike Fagan. Soft typing. In Programming Language Design and Implementation, pages 278--292, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Giuseppe Castagna, Giorgio Ghelli, and Giuseppe Longo. A calculus for overloaded functions with subtyping. Information and Computation, 117 (1): 115--135, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. M. Coppo, M. Dezani-Ciancaglini, and B. Venneri. Functional characters of solvable terms. Zeitschrift f. math. Logik und Grundlagen d. Math., 27: 45--58, 1981.Google ScholarGoogle Scholar
  6. Rowan Davies. Practical Refinement-Type Checking. PhD thesis, Carnegie Mellon University, 2005. Carnegie Mellon University-CS-05-110. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Rowan Davies and Frank Pfenning. Intersection types and computational effects. In ICFP, pages 198--208, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Jana Dunfield. Refined typechecking with Stardust. In Programming Languages meets Program Verification (PLPV '07), 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Jana Dunfield. Greedy bidirectional polymorphism. In ML Workshop, pages 15--26, 2009. https://research.cs.queensu.ca/home/jana/papers/poly/. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Jana Dunfield. Untangling typechecking of intersections and unions. In 2010 Workshop on Intersection Types and Related Systems, volume 45 of EPTCS, pages 59--70, 2011. arXiv:1101.4428v1 {cs.PL}.Google ScholarGoogle ScholarCross RefCross Ref
  11. Jana Dunfield. Twelf proofs accompanying this paper, March 2012. https://dl.acm.org/doi/10.1145/2364527.2364534.Google ScholarGoogle Scholar
  12. Jana Dunfield and Frank Pfenning. Type assignment for intersections and unions in call-by-value languages. In Found. Software Science and Computation Structures (FoSSaCS '03), pages 250--266, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Jana Dunfield and Frank Pfenning. Tridirectional typechecking. In Principles of Programming Languages, pages 281--292, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Tim Freeman and Frank Pfenning. Refinement types for ML. In Programming Language Design and Implementation, pages 268--277, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Alain Frisch, Giuseppe Castagna, and Véronique Benzaken. Semantic subtyping: dealing set-theoretically with function, union, intersection, and negation types. J. ACM, 55 (4): 1--64, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. J. Roger Hindley. Coppo-Dezani types do not correspond to propositional logic. Theoretical Computer Science, 28: 235--236, 1984.Google ScholarGoogle ScholarCross RefCross Ref
  17. J. Roger Hindley. Types with intersection: An introduction. Formal Aspects of Computing, 4: 470--486, 1992.Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Assaf J. Kfoury and J. B. Wells. Principality and type inference for intersection types using expansion variables. Theoretical Computer Science, 311 (1-3): 1--70, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. David MacQueen, Gordon Plotkin, and Ravi Sethi. An ideal model for recursive polymorphic types. Information and Control, 71: 95--130, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Peter Møller Neergaard and Harry G. Mairson. Types, potency, and idempotency: Why nonlinearity and amnesia make a type system work. In ICFP, pages 138--149, 2004.Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Frank Pfenning and Carsten Schürmann. System description: Twelf - a meta-logical framework for deductive systems. In Int'l Conf. Automated Deduction (CADE-16), pages 202--206, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Benjamin C. Pierce. Programming with intersection types, union types, and polymorphism. Technical Report Carnegie Mellon University-CS-91-106, Carnegie Mellon University, 1991a.Google ScholarGoogle Scholar
  23. Benjamin C. Pierce. Programming with intersection types and bounded polymorphism. PhD thesis, Carnegie Mellon University, 1991b. Technical Report Carnegie Mellon University-CS-91-205. Google ScholarGoogle Scholar
  24. Benjamin C. Pierce and David N. Turner. Local type inference. ACM Trans. Prog. Lang. Syst., 22: 1--44, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Garrel Pottinger. A type assignment for the strongly normalizable lambda-terms. In To H. B. Curry: Essays on Combinatory Logic, Lambda Calculus and Formalism, pages 561--577. Academic Press, 1980.Google ScholarGoogle Scholar
  26. John C. Reynolds. Preliminary design of the programming language Forsythe. Technical Report Carnegie Mellon University-CS-88-159, Carnegie Mellon University, 1988. http://doi.library.cmu.edu/10.1184/OCLC/18612825.Google ScholarGoogle Scholar
  27. John C. Reynolds. The coherence of languages with intersection types. In Theoretical Aspects of Computer Software, volume 526 of LNCS, pages 675--700. Springer, 1991. Google ScholarGoogle ScholarCross RefCross Ref
  28. John C. Reynolds. Design of the programming language Forsythe. Technical Report Carnegie Mellon University-CS-96-146, Carnegie Mellon University, 1996.Google ScholarGoogle Scholar
  29. Sam Tobin-Hochstadt and Matthias Felleisen. The design and implementation of Typed Scheme. In Principles of Programming Languages, pages 395--406, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Franklyn Turbak, Allyn Dimock, Robert Muller, and J. B. Wells. Compiling with polymorphic and polyvariant flow types. In Int'l Workshop on Types in Compilation, 1997.Google ScholarGoogle Scholar
  31. Twelf. Twelf wiki, 2012. http://twelf.org/wiki/Main_Page.Google ScholarGoogle Scholar
  32. Philip Wadler and Stephen Blott. How to make ad-hoc polymorphism less ad hoc. In Principles of Programming Languages, pages 60--76, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. J. B. Wells, Allyn Dimock, Robert Muller, and Franklyn Turbak. A calculus with polymorphic and polyvariant flow types. J. Functional Programming, 12 (3): 183--227, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Elaborating intersection and union types

    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 9
      ICFP '12
      September 2012
      368 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/2398856
      Issue’s Table of Contents
      • cover image ACM Conferences
        ICFP '12: Proceedings of the 17th ACM SIGPLAN international conference on Functional programming
        September 2012
        392 pages
        ISBN:9781450310543
        DOI:10.1145/2364527

      Copyright © 2012 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 9 September 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!