Hostname: page-component-8448b6f56d-xtgtn Total loading time: 0 Render date: 2024-04-23T19:09:55.141Z Has data issue: false hasContentIssue false

Elaborating intersection and union types

Published online by Cambridge University Press:  20 January 2014

JANA DUNFIELD*
Affiliation:
Max Planck Institute for Software Systems (MPI-SWS), Kaiserslautern and Saarbrücken, Germany (e-mail: jana.dunfield@gmail.com)
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

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.

Type
Articles
Copyright
Copyright © Cambridge University Press 2014 

References

Aiken, A., Wimmers, E. L. & Lakshman, T. K. (1994) Soft typing with conditional types. In Principles of Programming Languages, New York: ACM Press, pp. 163173.Google Scholar
Barbanera, F., Dezani-Ciancaglini, M. & de'Liguoro, U. (1995) Intersection and union types: syntax and semantics. Inf. Comput. 119, 202230.Google Scholar
Barendregt, H., Coppo, M. & Dezani-Ciancaglini, M. (1983) A filter lambda model and the completeness of type assignment. J. Symb. Log. 48 (4), 931940.Google Scholar
Cartwright, R. & Fagan, M. (1991) Soft typing. In Programming Language Design and Implementation, New York: ACM Press, pp. 278292.Google Scholar
Castagna, G., Ghelli, G. & Longo, G. (1995) A calculus for overloaded functions with subtyping. Inf. Comput. 117 (1), 115135.Google Scholar
Coppo, M., Dezani-Ciancaglini, M. & Venneri, B. (1981) Functional characters of solvable terms. Zeitschrift für mathematische Logik und Grundlagen der Mathematik 27, 4558.Google Scholar
Davies, R. (2005) Practical Refinement-Type Checking. PhD thesis, Carnegie Mellon University, CMU-CS-05-110.Google Scholar
Davies, R. & Pfenning, F. (2000) Intersection types and computational effects. In International Conference on Functional Programming (ICFP), pp. 198–208.Google Scholar
Dunfield, J. (2007) Refined typechecking with Stardust. In Programming Languages meets Program Verification (PLPV '07), New York: ACM Press, pp. 2132.Google Scholar
Dunfield, J. (2009) Greedy bidirectional polymorphism. In ML Workshop, pp. 15–26. Available at: http://www.cs.queensu.ca/~jana/papers/poly/Google Scholar
Dunfield, J. (2011) Untangling typechecking of intersections and unions. In Proceedings of the 2010 Workshop on Intersection Types and Related Systems, vol. 45 of EPTCS, pp. 59–70. arXiv: 1101.4428v1 [cs.PL].Google Scholar
Dunfield, J. (2012) Elaborating intersection and union types. In International Conference on Functional Programming (ICFP), pp. 17–28. arXiv: 1206.5386 [cs.PL].Google Scholar
Dunfield, J. (2013) Twelf proofs accompanying this work, September. Available at: http://www.cs.queensu.ca/~jana/intcomp-twelf-2013.tarGoogle Scholar
Dunfield, J. & Krishnaswami, N. R. (2013) Complete and easy bidirectional typechecking for higher-rank polymorphism. In International Conference on Functional Programming (ICFP). arXiv: 1306.6032 [cs.PL].Google Scholar
Dunfield, J. & Pfenning, F. (2003) Type assignment for intersections and unions in call-by-value languages. In Foundations of Software Science and Computation Structures (FoSSaCS '03), pp. 250–266.Google Scholar
Dunfield, J. & Pfenning, F. (2004) Tridirectional typechecking. In Principles of Programming Languages, New York: ACM Press, pp. 281292.Google Scholar
Freeman, T. & Pfenning, F. (1991) Refinement types for ML. In Programming Language Design and Implementation, New York: ACM Press, pp. 268277.Google Scholar
Frisch, A., Castagna, G. & Benzaken, V. (2008) Semantic subtyping: dealing set-theoretically with function, union, intersection, and negation types. J. ACM 55 (4), 164.Google Scholar
Gentzen, G. (1969) Investigations into logical deduction. In Collected Papers of Gerhard Gentzen, Szabo, M. (ed), North-Holland: Amsterdam, pp. 68131.Google Scholar
Hindley, J. R. (1984) Coppo–Dezani types do not correspond to propositional logic. Theor. Comput. Sci. 28, 235236.Google Scholar
Hindley, J. R. (1992) Types with intersection: An introduction. Form. Asp. Comput. 4, 470486.Google Scholar
Kfoury, A. J. & Wells, J. B. (2004) Principality and type inference for intersection types using expansion variables. Theor. Comput. Sci. 311 (1–3), 170.Google Scholar
Lopez-Escobar, E. G. K. (1985) Proof functional connectives. In Methods in Mathematical Logic, vol. 1130 of Lecture Notes in Mathematics, Springer: Berlin, pp. 208221.Google Scholar
MacQueen, D., Plotkin, G. & Sethi, R. (1986) An ideal model for recursive polymorphic types. Inf. Control 71, 95130.Google Scholar
Milner, R., Tofte, M., Harper, R. & MacQueen, D. (1997) The Definition of Standard ML (Revised). Cambridge: Massachusetts, USA, MIT Press.Google Scholar
Neergaard, P. M. & Mairson, H. G. (2004) Types, potency, and idempotency: why nonlinearity and amnesia make a type system work. In International Conference on Functional Programming (ICFP), pp. 138–149.Google Scholar
Pfenning, F. & Schürmann, C. (1999) System description: Twelf—a meta-logical framework for deductive systems. In International Conference on Automated Deduction (CADE-16), pp. 202–206.Google Scholar
Pierce, B. C. (1991) Programming with Intersection Types, Union Types, and Polymorphism. Technical Report CMU-CS-91-106, Carnegie Mellon University.Google Scholar
Pierce, B. C. & Turner, D. N. (2000) Local type inference. ACM Trans. Program. Lang. Syst. 22, 144.Google Scholar
Pottinger, G. (1980) A type assignment for the strongly normalizable lambda-terms. In To H.B. Curry: Essays on Combinatory Logic, Lambda Calculus and Formalism, Academic Press, pages 561577.Google Scholar
Rémy, D. (1989) Typechecking records and variants in a natural extension of ML. In Principles of Programming Languages, New York: ACM Press.Google Scholar
Reynolds, J. C. (1988) Preliminary Design of the Programming Language Forsythe. Technical Report CMU-CS-88-159, Carnegie Mellon University. http://doi.library.cmu.edu/10.1184/OCLC/18612825.Google Scholar
Reynolds, J. C. (1991) The coherence of languages with intersection types. In Theoretical Aspects of Computer Software, vol. 526 of LNCS, Springer: Berlin, pp. 675700.Google Scholar
Reynolds, J. C. (1996) Design of the Programming Language Forsythe. Technical Report CMU-CS-96-146, Carnegie Mellon University.Google Scholar
Tobin-Hochstadt, S. and Felleisen, M. (2008) The design and implementation of Typed Scheme. In Principles of Programming Languages, New York: ACM Press, pp. 395406.Google Scholar
Turbak, F., Dimock, A., Muller, R. & Wells, J. B. (1997) Compiling with polymorphic and polyvariant flow types. In International Workshop on Types in Compilation. Available at: http://cs.wellesley.edu/~fturbak/pubs/tic97.pdf.Google Scholar
Twelf. (2012) Twelf wiki. Available at: http://twelf.org/wiki/Main_Page.Google Scholar
Wadler, P. and Blott, S. (1989) How to make ad-hoc polymorphism less ad hoc. In Principles of Programming Languages, New York: ACM Press, pp. 6076.Google Scholar
Wells, J. B., Dimock, A., Muller, R. & Turbak, F. (2002) A calculus with polymorphic and polyvariant flow types. J. Funct. Program. 12 (3), 183227.Google Scholar
Wright, A. K. (1995) Simple imperative polymorphism. LISP Symb. Comput. 8 (4), 343355.Google Scholar
Submit a response

Discussions

No Discussions have been published for this article.