Advancements in mobile device computing power have made interactive web applications possible, allowing the web browser to render contents dynamically and support low-latency communication with the server. This comes at a cost to the developer, who now needs to reason more about correctness of communication patterns in their application as web applications support more complex communication patterns.
Multiparty session types (MPST) provide a framework for verifying conformance of implementations to their prescribed communication protocol. Existing proposals for applying the MPST framework in application developments either neglect the event-driven nature of web applications, or lack compatibility with industry tools and practices, which discourages mainstream adoption by web developers.
In this paper, we present an implementation of the MPST framework for developing interactive web applications using familiar industry tools using TypeScript and the React.js framework. The developer can use the Scribble protocol language to specify the protocol and use the Scribble toolchain to validate and obtain the local protocol for each role. The local protocol describes the interactions of the global communication protocol observed by the role. We encode the local protocol into TypeScript types, catering for server-side and client-side targets separately. We show that our encoding guarantees that only implementations which conform to the protocol can type-check. We demonstrate the effectiveness of our approach through a web-based implementation of the classic Noughts and Crosses game from an MPST formalism of the game logic.
[1]
Simon Fowler,et al.
Model-View-Update-Communicate: Session Types meet the Elm Architecture
,
2019,
Dagstuhl Artifacts Ser..
[2]
Hongwei Xi,et al.
Applied Type System: Extended Abstract
,
2003,
TYPES.
[3]
Nobuko Yoshida,et al.
Explicit Connection Actions in Multiparty Session Types
,
2017,
FASE.
[4]
Nobuko Yoshida,et al.
Multiparty Compatibility in Communicating Automata: Characterisation and Synthesis of Global Session Types
,
2013,
ICALP.
[5]
Martín Abadi,et al.
Understanding TypeScript
,
2014,
ECOOP.
[6]
Nobuko Yoshida,et al.
Multiparty Session Type-safe Web Development with Static Linearity
,
2019,
PLACES@ETAPS.
[7]
Nobuko Yoshida,et al.
The Scribble Protocol Language
,
2013,
TGC.
[8]
Luca Padovani,et al.
A Gentle Introduction to Multiparty Asynchronous Session Types
,
2015,
SFM.
[9]
Rumyana Neykova.
Session Types Go Dynamic or How to Verify Your Python Conversations
,
2013,
PLACES.
[10]
Nobuko Yoshida,et al.
Hybrid Session Verification Through Endpoint API Generation
,
2016,
FASE.
[11]
Luca Padovani,et al.
Concurrent Typestate-Oriented Programming in Java
,
2019,
PLACES@ETAPS.