Set-theoretic types for polymorphic variants

Type: Preprint

Publication Date: 2016-08-29

Citations: 26

DOI: https://doi.org/10.1145/2951913.2951928

Download PDF

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 poly-morphic 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.

Locations

  • arXiv (Cornell University) - View - PDF
  • HAL (Le Centre pour la Communication Scientifique Directe) - View - PDF
  • DataCite API - View

Similar Works

Action Title Year Authors
+ Set-theoretic types for polymorphic variants 2016 Giuseppe Castagna
Tommaso Petrucciani
Kim Nguyễn
+ Refinement Kinds: Type-safe Programming with Practical Type-level Computation (Extended Version) 2019 Luı́s Caires
Bernardo Toninho
+ Refinement Kinds: Type-safe Programming with Practical Type-level Computation (Extended Version) 2019 Luı́s Caires
Bernardo Toninho
+ Polymorphic Functional Type Theory 1994 Roy L. Crole
+ GADT meet Subtyping 2012 Gabriel Scherer
Didier Rémy
+ GADT meet Subtyping 2012 Gabriel Scherer
Didier Rémy
+ Resource Polymorphism 2018 Guillaume Munch-Maccagnoni
+ Resource Polymorphism 2018 Guillaume Munch-Maccagnoni
+ Parametricity for Nested Types and GADTs. 2021 Patricia Johann
Enrico Ghiorzi
Daniel Jeffries
+ PDF Chat Parametricity for Nested Types and GADTs 2021 Patricia Johann
Enrico Ghiorzi
+ PDF Chat Revisiting Occurrence Typing 2019 Giuseppe Castagna
Victor Lanvin
Mickaël Laurent
Kim Nguyễn
+ Coeffects for Sharing and Mutation 2022 Riccardo Bianchini
Francesco Dagnino
Paola Giannini
E. Zucca
Marco Servetto
+ PDF Chat Coeffects for sharing and mutation 2022 Riccardo Bianchini
Francesco Dagnino
Paola Giannini
Elena Zucca
Marco Servetto
+ PDF Chat Law and Order for Typestate with Borrowing 2024 Hannes Saffrich
Yuki Nishida
Peter Thiemann
+ PDF Chat Law and Order for Typestate with Borrowing 2024 Hannes Saffrich
Yuki Nishida
Peter Thiemann
+ Qualifying System F <sub>&lt;:</sub> : Some Terms and Conditions May Apply 2024 Edward Lee
Yaoyu Zhao
Ondřej Lhoták
James You
Kavin Satheeskumar
Jonathan Immanuel Brachthäuser
+ PDF Chat Type Classes for Lightweight Substructural Types 2015 Edward Gan
Jesse A. Tov
Greg Morrisett
+ PDF Chat Free Foil: Generating Efficient and Scope-Safe Abstract Syntax 2024 Nikolai Kudasov
Renata Shakirova
Egor Shalagin
Karina Tyulebaeva
+ PDF Chat Improving Type Error Messages in OCaml 2015 Arthur Charguéraud
+ Qualifying System F-sub 2023 Edward A. Lee
Yaoyu Zhao
James You
Kavin Satheeskumar
Ondřej Lhoták
Jonathan Immanuel Brachthäuser