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.
Supplemental Material
Available for Download
Auxiliary material for "Elaborating Intersection and Union Types", ICFP 2012: This archive contains Twelf source files (sources.cfg, *.elf) and a brief guide (icfp02-dunfield-supp.pdf).
- Alexander Aiken, Edward L. Wimmers, and T. K. Lakshman. Soft typing with conditional types. In Principles of Programming Languages, pages 163--173, 1994. Google Scholar
Digital Library
- Franco Barbanera, Mariangiola Dezani-Ciancaglini, and Ugo de'Liguoro. Intersection and union types: syntax and semantics. Information and Computation, 119: 202--230, 1995. Google Scholar
Digital Library
- Robert Cartwright and Mike Fagan. Soft typing. In Programming Language Design and Implementation, pages 278--292, 1991. Google Scholar
Digital Library
- Giuseppe Castagna, Giorgio Ghelli, and Giuseppe Longo. A calculus for overloaded functions with subtyping. Information and Computation, 117 (1): 115--135, 1995. Google Scholar
Digital Library
- 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 Scholar
- Rowan Davies. Practical Refinement-Type Checking. PhD thesis, Carnegie Mellon University, 2005. Carnegie Mellon University-CS-05-110. Google Scholar
Digital Library
- Rowan Davies and Frank Pfenning. Intersection types and computational effects. In ICFP, pages 198--208, 2000. Google Scholar
Digital Library
- Jana Dunfield. Refined typechecking with Stardust. In Programming Languages meets Program Verification (PLPV '07), 2007. Google Scholar
Digital Library
- Jana Dunfield. Greedy bidirectional polymorphism. In ML Workshop, pages 15--26, 2009. https://research.cs.queensu.ca/home/jana/papers/poly/. Google Scholar
Digital Library
- 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 Scholar
Cross Ref
- Jana Dunfield. Twelf proofs accompanying this paper, March 2012. https://dl.acm.org/doi/10.1145/2364527.2364534.Google Scholar
- 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 Scholar
Digital Library
- Jana Dunfield and Frank Pfenning. Tridirectional typechecking. In Principles of Programming Languages, pages 281--292, 2004. Google Scholar
Digital Library
- Tim Freeman and Frank Pfenning. Refinement types for ML. In Programming Language Design and Implementation, pages 268--277, 1991. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- J. Roger Hindley. Coppo-Dezani types do not correspond to propositional logic. Theoretical Computer Science, 28: 235--236, 1984.Google Scholar
Cross Ref
- J. Roger Hindley. Types with intersection: An introduction. Formal Aspects of Computing, 4: 470--486, 1992.Google Scholar
Digital Library
- 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 Scholar
Digital Library
- David MacQueen, Gordon Plotkin, and Ravi Sethi. An ideal model for recursive polymorphic types. Information and Control, 71: 95--130, 1986. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Benjamin C. Pierce. Programming with intersection types, union types, and polymorphism. Technical Report Carnegie Mellon University-CS-91-106, Carnegie Mellon University, 1991a.Google Scholar
- 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 Scholar
- Benjamin C. Pierce and David N. Turner. Local type inference. ACM Trans. Prog. Lang. Syst., 22: 1--44, 2000. Google Scholar
Digital Library
- 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 Scholar
- 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 Scholar
- 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 Scholar
Cross Ref
- John C. Reynolds. Design of the programming language Forsythe. Technical Report Carnegie Mellon University-CS-96-146, Carnegie Mellon University, 1996.Google Scholar
- Sam Tobin-Hochstadt and Matthias Felleisen. The design and implementation of Typed Scheme. In Principles of Programming Languages, pages 395--406, 2008. Google Scholar
Digital Library
- 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 Scholar
- Twelf. Twelf wiki, 2012. http://twelf.org/wiki/Main_Page.Google Scholar
- Philip Wadler and Stephen Blott. How to make ad-hoc polymorphism less ad hoc. In Principles of Programming Languages, pages 60--76, 1989. Google Scholar
Digital Library
- 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 Scholar
Digital Library
Index Terms
Elaborating intersection and union types
Recommendations
Elaborating intersection and union types
ICFP '12: Proceedings of the 17th ACM SIGPLAN international conference on Functional programmingDesigning 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 ...
Gradual typing with union and intersection types
We propose a type system for functional languages with gradual types and set-theoretic type connectives and prove its soundness. In particular, we show how to lift the definition of the domain and result type of an application from non-gradual types to ...
Disjoint intersection types
ICFP 2016: Proceedings of the 21st ACM SIGPLAN International Conference on Functional ProgrammingDunfield showed that a simply typed core calculus with intersection types and a merge operator is able to capture various programming language features. While his calculus is type-safe, it is not coherent: different derivations for the same expression ...







Comments