You Have Mail: Set-Theoretic Types for Actors
We present a type system for the processes of Elixir, a dynamic language based on the actor model whose static type system covers only its functional core. Each process is typed by $\mathtt{pid}(t)$, where the ``interface'' $t$ is the type of the messages the process expects in its mailbox: sends are checked against the recipient's interface, and receives rely on the interface of the process that performs them. One of the difficulties of typing Elixir is that mailboxes are implicit: a function shipped in a message may evaluate $\mathtt{self()}$ and execute receive instructions, and both refer to whichever process eventually runs the function---$\mathtt{self()}$ returns that process's pid, receive reads that process's mailbox---so the mailbox they act on is not known where the function is written. We solve this problem by inferring, for every function, bounds on the type of the mailboxes it can be used with; as a result, the system types higher-order functions that travel in messages even when they contain reference to $\mathtt{self()}$ and receive instructions. The only new annotation the programmer writes is the interface of each spawned process; everything else is inferred by…
- arXiv
- 2611.26563
- Authors
- Giuseppe Castagna, Luca Padovani, Daniele Varacca, Amine Nasri
- Categories
- cs.PL