Set-Theoretic types for polymorphic variants

被引:0
作者
Castagna G. [1 ]
Petrucciani T. [1 ,2 ]
Nguyán K. [3 ]
机构
[1] CNRS, Univ Paris Diderot, Sorbonne Paris Cité, Paris
[2] DIBRIS, Università Degli Studi di Genova, Genova
[3] LRI, Université Paris-Sud, Orsay
来源
| 1600年 / Association for Computing Machinery, 2 Penn Plaza, Suite 701, New York, NY 10121-0701, United States卷 / 51期
关键词
type constraints; Type reconstruction; union types;
D O I
10.1145/2951913.2951928
中图分类号
学科分类号
摘要
Polymorphic variants are a useful feature of the OCaml language whose current definition and implementation rely on kinding constraints to simulate a subtyping relation via unification. This yields an awkward formalization and results in a type system whose behaviour is in some cases unintuitive and/or unduly restrictive. In this work, we present an alternative formalization of polymorphic variants, based on set-Theoretic types and subtyping, that yields a cleaner and more streamlined system. Our formalization is more expressive than the current one (it types more programs while preserving type safety), it can internalize some meta-Theoretic properties, and it removes some pathological cases of the current implementation resulting in a more intuitive and, thus, predictable type system. More generally, this work shows how to add full-fledged union types to functional languages of the ML family that usually rely on the Hindley-Milner type system. As an aside, our system also improves the theory of semantic subtyping, notably by proving completeness for the type reconstruction algorithm. © 2016 ACM.
引用
收藏
页码:378 / 391
页数:13
相关论文
共 28 条
  • [1] Benzaken V., Castagna G., Frisch A., CDuce: An XML-centric generalpurpose language, ACM SIGPLAN International Conference on Functional Programming (ICFP), pp. 51-63, (2003)
  • [2] Blume M., Acar U.A., Chae W., Exception handlers as extensible cases, Proceedings of the 6th Asian Symposium on Programming Languages and Systems (APLAS), LNCS, pp. 273-289, (2008)
  • [3] Bonsangue M., Rot J., Ancona D., De Boer F., Rutten J., A coalgebraic foundation for coinductive union types, Automata, Languages, and Programming-41st International Colloquium (ICALP) Volume 8573 of Lecture Notes in Computer Science, pp. 62-73, (2014)
  • [4] Castagna G., Xu Z., Set-Theoretic foundation of parametric polymorphism and subtyping, ACM SIGPLAN International Conference on Functional Programming (ICFP, pp. 94-106, (2011)
  • [5] Castagna G., Nguyen K., Xu Z., Im H., Lenglet S., Padovani L., Polymorphic functions with set-Theoretic types. Part 1: Syntax, semantics, and evaluation, ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL, pp. 5-17, (2014)
  • [6] Castagna G., Nguyen K., Xu Z., Abate P., Polymorphic functions with set-Theoretic types. Part 2: Local type inference and type reconstruction, ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), pp. 289-302, (2015)
  • [7] Castagna G., Petrucciani T., Nguyen K., Set-Theoretic Types for Polymorphic Variants. Technical Report, Université Paris Diderot, May 2016. Extended Version
  • [8] Polymorphic Variant Difference, (2000)
  • [9] OCaml Mailing List Post. [CAML-LIST 3]
  • [10] Getting Rid of Impossible Polymorphic Variant Tags from Inferred Types