Multiparty Session Programming with Global Protocol Combinators

Multiparty Session Types (MPST) is a typing discipline for communication protocols. It ensures the absence of communication errors and deadlocks for well-typed communicating processes. The state-of-the-art implementations of the MPST theory rely on (1) runtime linearity checks to ensure correct usage of communication channels and (2) external domain-specific languages for specifying and verifying multiparty protocols. To overcome these limitations, we propose a library for programming with global combinators -- a set of functions for writing and verifying multiparty protocols in OCaml. Local behaviours for all processes in a protocol are inferred at once from a global combinator. We formalise global combinators and prove a sound realisability of global combinators -- a well-typed global combinator derives a set of local types, by which typed endpoint programs can ensure type and communication safety. Our approach enables fully-static verification and implementation of the whole protocol, from the protocol specification to the process implementations, to happen in the same language. We compare our implementation to untyped and continuation-passing style implementations, and demonstrate its expressiveness by implementing a plethora of protocols. We show our library can interoperate with existing libraries and services, implementing DNS (Domain Name Service) protocol and the OAuth (Open Authentication) protocol.

[1]  Nobuko Yoshida,et al.  Session-ocaml: A Session-Based Library with Polarities and Lenses , 2017, COORDINATION.

[2]  Luca Padovani Context-Free Session Type Inference , 2017, ESOP.

[3]  Riccardo Pucella,et al.  Stateful Contracts for Affine Types , 2010, ESOP.

[4]  Nobuko Yoshida,et al.  A Linear Decomposition of Multiparty Sessions for Safe Distributed Programming , 2017, ECOOP.

[5]  Simon J. Gay,et al.  Subtyping for session types in the pi calculus , 2005, Acta Informatica.

[6]  Gabriel Scherer,et al.  Merlin: a language server for OCaml (experience report) , 2018, Proc. ACM Program. Lang..

[7]  Nobuko Yoshida,et al.  Effects as sessions, sessions as effects , 2016, POPL.

[8]  Nobuko Yoshida,et al.  Explicit Connection Actions in Multiparty Session Types , 2017, FASE.

[9]  Dirk Merkel,et al.  Docker: lightweight Linux containers for consistent development and deployment , 2014 .

[10]  Benjamin C. Pierce,et al.  Combinators for bi-directional tree transformations: a linguistic approach to the view update problem , 2005, POPL '05.

[11]  Edwin Brady Type-driven Development of Concurrent Communicating Systems , 2017, Comput. Sci..

[12]  Nobuko Yoshida,et al.  Multiparty Session Types Meet Communicating Automata , 2012, ESOP.

[13]  Loris D'Antoni,et al.  Global Progress in Dynamically Interleaved Multiparty Sessions , 2008, CONCUR.

[14]  Mitchell Wand,et al.  Type inference for record concatenation and multiple inheritance , 1989, [1989] Proceedings. Fourth Annual Symposium on Logic in Computer Science.

[15]  Nobuko Yoshida,et al.  Hybrid Session Verification Through Endpoint API Generation , 2016, FASE.

[16]  Vivek Sarkar,et al.  Savina - An Actor Benchmark Suite: Enabling Empirical Evaluation of Actor Libraries , 2014, AGERE!@SPLASH.

[17]  Nicolas Wu,et al.  Profunctor Optics: Modular Data Accessors , 2017, Art Sci. Eng. Program..

[18]  Nobuko Yoshida,et al.  Distributed programming using role-parametric session types in go: statically-typed endpoint APIs for dynamically-instantiated communication structures , 2019, Proc. ACM Program. Lang..

[19]  Yaron Minsky OCaml for the masses , 2011, CACM.

[20]  Ilya Sergey,et al.  Distributed Protocol Combinators , 2019, PADL.

[21]  Nobuko Yoshida,et al.  Less is more: multiparty session types revisited , 2019, Proc. ACM Program. Lang..

[22]  Dimitrios Kouzapas,et al.  Typechecking protocols with Mungo and StMungo , 2016, PPDP.

[23]  Jérôme Vouillon,et al.  Eliom: A Core ML Language for Tierless Web Programming , 2016, APLAS.

[24]  Shoji Yuen,et al.  Multiparty Session Programming with Global Protocol Combinators , 2020, ECOOP.

[25]  Philip Wadler,et al.  Coherence Generalises Duality: A Logical Explanation of Multiparty Session Types , 2016, CONCUR.

[26]  Davide Sangiorgi,et al.  Session types revisited , 2012, PPDP.

[27]  Riccardo Pucella,et al.  Haskell session types with (almost) no class , 2008, Haskell '08.

[28]  Simon J. Gay Subtyping Supports Safe Session Substitution , 2016, A List of Successes That Can Change the World.

[29]  Nick Benton Jingle Bells: Solving the Santa Claus Problem in Polyphonic C , 2003 .

[30]  Nobuko Yoshida,et al.  Multiparty Compatibility in Communicating Automata: Characterisation and Synthesis of Global Session Types , 2013, ICALP.

[31]  Luca Padovani,et al.  A Gentle Introduction to Multiparty Asynchronous Session Types , 2015, SFM.

[32]  Nobuko Yoshida,et al.  Dynamic multirole session types , 2011, POPL '11.

[33]  Nobuko Yoshida,et al.  Lightweight Session Programming in Scala , 2016, ECOOP.

[34]  Raheel Ahmad,et al.  The π-Calculus: A theory of mobile processes , 2008, Scalable Comput. Pract. Exp..

[35]  Nobuko Yoshida,et al.  Multiparty asynchronous session types , 2008, POPL '08.

[36]  Luís Caires,et al.  Multiparty Session Types Within a Canonical Binary Theory, and Beyond , 2016, FORTE.

[37]  Mariangiola Dezani-Ciancaglini,et al.  Precise subtyping for synchronous multiparty sessions , 2016, PLACES.

[38]  Bernardo Toninho,et al.  Higher-Order Processes, Functions, and Sessions: A Monadic Integration , 2013, ESOP.

[39]  Nobuko Yoshida,et al.  A session type provider: compile-time API generation of distributed protocols with refinements in F# , 2018, CC.

[40]  John H. Reppy Concurrent ML: Design, Application and Semantics , 1993, Functional Programming, Concurrency, Simulation and Automated Reasoning.

[41]  Dick Hardt,et al.  The OAuth 2.0 Authorization Framework , 2012, RFC.

[42]  Sam Lindley,et al.  Embedding session types in Haskell , 2016, Haskell.

[43]  Ilya Sergey,et al.  Programming and proving with distributed protocols , 2017, Proc. ACM Program. Lang..

[44]  Benjamin C. Pierce,et al.  A record calculus based on symmetric concatenation , 1991, POPL '91.

[45]  Fabrizio Montesi,et al.  Deadlock-freedom-by-design: multiparty asynchronous global programming , 2013, POPL.

[46]  António Ravara,et al.  Behavioural Types: from Theory to Tools , 2017 .

[47]  Jérôme Vouillon,et al.  Lwt: a cooperative thread library , 2008, ML '08.

[48]  David J. Scott,et al.  Unikernels: the rise of the virtual library operating system , 2013, CACM.

[49]  Luca Padovani,et al.  A simple library implementation of binary sessions* , 2016, Journal of Functional Programming.

[50]  Davide Sangiorgi,et al.  Typing and subtyping for mobile processes , 1993, [1993] Proceedings Eighth Annual IEEE Symposium on Logic in Computer Science.

[51]  Jacques Garrigue,et al.  Lightweight Linearly-typed Programming with Lenses and Monads , 2019, J. Inf. Process..

[52]  Davide Sangiorgi,et al.  The Pi-Calculus - a theory of mobile processes , 2001 .