Programming with union, intersection, and negation types

11/05/2021
by   Giuseppe Castagna, et al.
0

In this essay, I present the advantages and, I dare say, the beauty of programming in a language with set-theoretic types, that is, types that include union, intersection, and negation type connectives. I show by several examples how set-theoretic types are necessary to type some common programming patterns, but also how they play a key role in typing several language constructs-from branching and pattern matching to function overloading and type-cases-very precisely. I start by presenting the theory of types known as semantic subtyping and extend it to include polymorphic types. Next, I discuss the design of languages that use these types. I start by defining a theoretical framework that covers all the examples given in the first part of the presentation. Since the system of the framework cannot be effectively implemented, I then describe three effective restrictions of this system: (i) a polymorphic language with explicitly-typed functions, (ii) an implicitly-typed polymorphic languageà la Hindley-Milner, and (iii) a monomorphic language that, by implementing classic union-elimination, precisely reconstructs intersection types for functions and implements a very general form of occurrence typing. I conclude the presentation with a short overview of other aspects of these languages, such as pattern matching, gradual typing, and denotational semantics.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
07/12/2019

Revisiting Occurrence Typing

We revisit occurrence typing, a technique to refine the type of variable...
research
02/24/2023

Set-theoretic Types for Erlang

Erlang is a functional programming language with dynamic typing. The lan...
research
11/05/2020

Towards a more perfect union type

We present a principled theoretical framework for inferring and checking...
research
10/12/2018

Semantic subtyping for non-strict languages

Semantic subtyping is an approach to define subtyping relations for type...
research
06/10/2023

The Design Principles of the Elixir Type System

Elixir is a dynamically-typed functional language running on the Erlang ...
research
06/11/2021

Union and intersection contracts are hard, actually

Union and intersection types are a staple of gradually typed language su...
research
02/03/2016

Image and Information

A well-known old adage says that "A picture is worth a thousand words!"...

Please sign up or login with your details

Forgot password? Click here to reset