a specific protocol follows a global type. In (Harvey
et al., 2021) and more in general in the Stardust project
(Stardust, 2022), EnsembleS is introduced. This is an
actor language leveraging multiparty session types to
provide compile-time verification of safe dynamic run-
time adaptation. The focus of their work is protocol
adaptation in the face of actor failures.
We extended to FErlang the results of (Castellani
et al., 2020), where the communication between pro-
cesses is synchronous and the operation of starting and
ending delegation is assumed to be atomic. The asyn-
chronicity of FErlang, in contrast, allows more paral-
lelism, but since requesting/accepting forward/back-
ward delegation are non-atomic, periods exist in which
the principal and/or the delegate are not registered, so
messages sent to them could be lost. Our type check-
ing system precisely ensures that this cannot happen
if the actors follow the protocol prescribed by the ses-
sion types obtained as projection from a global type: it
ensures that the system is lock-free and has no orphan
messages.
6 CONCLUSIONS
In this work, we present an Erlang implementation for
multiparty protocols using a reduced, yet significant
set of Erlang constructs (FErlang), including the
communication primitives, send and receive, and
constructs for delegation. For the description of
delegation at the global type level we use the global
types introduced in (Castellani et al., 2020) which
include explicit primitives for starting and ending
delegation. We formalized and implemented a
projection from global types on session types that
derives the expected behaviour of single participants
from the global protocol. We defined a type system for
FErlang and implemented a parser and type checker
for it. The implementation was done using the meta
compiler JastAdd, resulting in a system which can be
easily extended to include new syntactic constructs
(for FErlang, global and session types) and syntax
directed translations.
For future work, in addition to using the tool on
other protocols, we have several directions. On one
side the current tool could be improved by tracking
errors found during type checking; this could be done
by defining in JastAdd further aspects to collect typ-
ing errors and showing them to the user. Moreover
we could implement a GUI to help the user with the
interaction. On the other hand, still leveraging on the
JastAdd implementation we could also use the session
type projection of a global type to generate a skeleton
for the Erlang modules implementing the processes of
the participants, as done in (Cutner and Yoshida, 2021)
for Rust. The user could then customize that code
relying on the fact that communications are correct.
ACKNOWLEDGEMENTS
We thank the anonymous referees for helpful com-
ments.
REFERENCES
Castellani, I., Dezani-Ciancaglini, M., and Giannini, P.
(2019). Reversible sessions with flexible choices. Acta
Informatica, 56(7-8):553–583.
Castellani, I., Dezani-Ciancaglini, M., Giannini, P., and
Horne, R. (2020). Global types with internal dele-
gation. Theoretical Computer Science, 807:128–153.
Coppo, M., Dezani-Ciancaglini, M., Padovani, L., and
Yoshida, N. (2015). A gentle introduction to multi-
party asynchronous session types. In Formal Methods
for Multicore Programming, volume 9104 of LNCS,
pages 146–178. Springer.
Cutner, Z. and Yoshida, N. (2021). Safe session-based asyn-
chronous coordination in rust. In COORDINATION,
volume 12717 of LNCS, pages 80–89. Springer.
Erlang (2022). Erlang doc. https://www.erlang.org. Ac-
cessed: 18-4-2022.
Fowler, S. (2016). An Erlang implementation of multiparty
session actors. In ICE, volume 223 of EPTCS, pages
36–50.
Harvey, P., Fowler, S., Dardha, O., and Gay, S. J. (2021).
Multiparty session types for safe runtime adaptation in
an actor language. In ECOOP, volume 194 of LIPIcs,
pages 10:1–10:30. Schloss Dagstuhl - Leibniz-Zentrum
f
¨
ur Informatik.
Hedin, G. (2011). An Introductory Tutorial on JastAdd
Attribute Grammars, pages 166–200. Springer Berlin
Heidelberg, Berlin, Heidelberg.
Honda, K., Yoshida, N., and Carbone, M. (2008). Multiparty
asynchronous session types. In POPL, pages 273–284.
ACM Press.
Mostrous, D. and Vasconcelos, V. T. (2011). Session typ-
ing for a featherweight erlang. In COORDINATION,
volume 6721 of LNCS, pages 95–109. Springer.
Neykova, R. and Yoshida, N. (2017). Multiparty session
actors. Logical Methods in Computer Science, 13(1).
Stardust (2022). Stardust: Session Types for Reliable Dis-
tributed Systems. https://epsrc-stardust.github.io/. Ac-
cessed: 18-4-2022.
Multiparty-session-types Coordination for Core Erlang
541