A session type provider: compile-time API generation of distributed protocols with refinements in F#

We present a library for the specification and implementation of distributed protocols in native F# (and other .NET languages) based on multiparty session types (MPST). There are two main contributions. Our library is the first practical development of MPST to support what we refer to as interaction refinements: a collection of features related to the refinement of protocols, such as message-type refinements (value constraints) and message value dependent control flow. A well-typed endpoint program using our library is guaranteed to perform only compliant session I/O actions w.r.t. to the refined protocol, up to premature termination. Second, our library is developed as a session type provider, that performs on-demand compile-time protocol validation and generation of protocol-specific .NET types for users writing the distributed endpoint programs. It is implemented by extending and integrating Scribble (a toolchain for MPST) with an SMT solver into the type providers framework. The safety guarantees are achieved by a combination of static type checking of the generated types for messages and I/O operations, correctness by construction from code generation, and automated inlining of assertions.

[1]  Davide Ancona,et al.  Behavioral Types in Programming Languages , 2016, Found. Trends Program. Lang..

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

[3]  Laura Bocchi,et al.  A Theory of Design-by-Contract for Distributed Multiparty Interactions , 2010, CONCUR.

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

[5]  Vasco Thudichum Vasconcelos,et al.  Linearly Refined Session Types , 2012, LINEARITY.

[6]  Don Syme,et al.  Types from data: making structured data first-class citizens in F# , 2016, PLDI.

[7]  Bengt Nordström,et al.  Types and Specifications , 1983, IFIP Congress.

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

[9]  Vasco Thudichum Vasconcelos,et al.  A Concurrent Programming Language with Refined Session Types , 2013, SEFM Workshops.

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

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

[12]  Luca Padovani,et al.  Global progress for dynamically interleaved multiparty sessions , 2014, Mathematical Structures in Computer Science.

[13]  Bernardo Toninho,et al.  Dependent session types via intuitionistic linear type theory , 2011, PPDP.

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

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

[16]  Frank Pfenning,et al.  Refinement types for ML , 1991, PLDI '91.

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

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

[19]  Vasco Thudichum Vasconcelos,et al.  Linear type theory for asynchronous session types , 2009, Journal of Functional Programming.

[20]  Vasco Thudichum Vasconcelos,et al.  Language Primitives and Type Discipline for Structured Communication-Based Programming Revisited: Two Systems for Higher-Order Session Communication , 1998, SecReT@ICALP.

[21]  Matthew Might,et al.  Continuations and transducer composition , 2006, PLDI '06.

[22]  Bernardo Toninho,et al.  Certifying data in multiparty session types , 2017, J. Log. Algebraic Methods Program..