The Design Principles of the Elixir Type System

06/10/2023
by   Giuseppe Castagna, et al.
0

Elixir is a dynamically-typed functional language running on the Erlang Virtual Machine, designed for building scalable and maintainable applications. Its characteristics have earned it a surging adoption by hundreds of industrial actors and tens of thousands of developers. Static typing seems nowadays to be the most important request coming from the Elixir community. We present a gradual type system we plan to include in the Elixir compiler, outline its characteristics and design principles, and show by some short examples how to use it in practice. Developing a static type system suitable for Erlang's family of languages has been an open research problem for almost two decades. Our system transposes to this family of languages a polymorphic type system with set-theoretic types and semantic subtyping. To do that, we had to improve and extend both semantic subtyping and the typing techniques thereof, to account for several characteristics of these languages – and of Elixir in particular – such as the arity of functions, the use of guards, a uniform treatment of records and dictionaries, the need for a new sound gradual typing discipline that does not rely on the insertion at compile time of specific run-time type-tests but, rather, takes into account both the type tests performed by the virtual machine and those explicitly added by the programmer. The system presented here is "gradually" being implemented and integrated in Elixir, but a prototype implementation is already available. The aim of this work is to serve as a longstanding reference that will be used to introduce types to Elixir programmers, as well as to hint at some future directions and possible evolutions of the Elixir language.

READ FULL TEXT

page 7

page 11

page 12

page 13

page 16

research
01/28/2021

Putting gradual types to work

In this paper, we describe our experience incorporating gradual types in...
research
12/17/2019

Decidable Tag-Based Semantic Subtyping for Nominal Types, Tuples, and Unions

Semantic subtyping enables simple, set-theoretical reasoning about types...
research
07/01/2019

The Semantics of Rank Polymorphism

Iverson's APL and its descendants (such as J, K and FISh) are examples o...
research
11/05/2021

Programming with union, intersection, and negation types

In this essay, I present the advantages and, I dare say, the beauty of p...
research
02/24/2023

Set-theoretic Types for Erlang

Erlang is a functional programming language with dynamic typing. The lan...
research
10/30/2018

Dynamic Type Inference for Gradual Hindley--Milner Typing

Garcia and Cimini study a type inference problem for the ITGL, an implic...
research
07/12/2019

Revisiting Occurrence Typing

We revisit occurrence typing, a technique to refine the type of variable...

Please sign up or login with your details

Forgot password? Click here to reset