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
18 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. When Subtyping Constraints Liberate: A Novel Type Inference Approach for First-Class Polymorphism;Proceedings of the ACM on Programming Languages;2024-01-05
2. Polymorphic Type Inference for Dynamic Languages;Proceedings of the ACM on Programming Languages;2024-01-05
3. Making a Type Difference: Subtraction on Intersection Types as Generalized Record Operations;Proceedings of the ACM on Programming Languages;2023-01-09
4. 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
5. MLstruct: principal type inference in a Boolean algebra of structural types;Proceedings of the ACM on Programming Languages;2022-10-31