Affiliation:
1. University of Paris Diderot, France
2. University of Genoa, Italy / University of Paris Diderot, France
3. University of Paris-Sud, France
Abstract
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.
Publisher
Association for Computing Machinery (ACM)
Subject
Computer Graphics and Computer-Aided Design,Software
Cited by
15 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Making a Type Difference: Subtraction on Intersection Types as Generalized Record Operations;Proceedings of the ACM on Programming Languages;2023-01-09
2. Simple Extensible Programming through Precisely-Typed Open Recursion;Companion Proceedings of the 2022 ACM SIGPLAN International Conference on Systems, Programming, Languages, and Applications: Software for Humanity;2022-11-29
3. Set-theoretic Types for Erlang;Proceedings of the 34th Symposium on Implementation and Application of Functional Languages;2022-08-31
4. Revisiting occurrence typing;Science of Computer Programming;2022-05
5. On type-cases, union elimination, and occurrence typing;Proceedings of the ACM on Programming Languages;2022-01-12