# Multiparty Session Type-safe Web Development with Static Linearity

**Authors:** Jonathan King (Imperial College London & Habito), Nicholas Ng, (Imperial College London), Nobuko Yoshida (Imperial College London)

arXiv: 1904.01287 · 2019-04-03

## TL;DR

This paper introduces a static verification technique for web applications using multiparty session types and type-level encoding in PureScript, ensuring communication correctness in interactive web apps.

## Contribution

It presents a novel approach combining Scribble protocols, FSM projection, and type-level encoding in PureScript to guarantee protocol adherence at compile time.

## Key findings

- Successfully applied to a web-based Battleship game.
- Ensures communication follows specified protocols.
- Leverages PureScript's type system for static linearity guarantees.

## Abstract

Modern web applications can now offer desktop-like experiences from within the browser, thanks to technologies such as WebSockets, which enable low-latency duplex communication between the browser and the server. While these advances are great for the user experience, they represent a new responsibility for web developers who now need to manage and verify the correctness of more complex and potentially stateful interactions in their application. In this paper, we present a technique for developing interactive web applications that are statically guaranteed to communicate following a given protocol. First, the global interaction protocol is described in the Scribble protocol language -- based on multiparty session types. Scribble protocols are checked for well-formedness, and then each role is projected to a Finite State Machine representing the structure of communication from the perspective of the role. We use source code generation and a novel type-level encoding of FSMs using multi-parameter type classes to leverage the type system of the target language and guarantee only programs that communicate following the protocol will type check.   Our work targets PureScript -- a functional language that compiles to JavaScript -- which crucially has an expressive enough type system to provide static linearity guarantees. We demonstrate the effectiveness of our approach through a web-based Battleship game where communication is performed through WebSocket connections.

## Full text

_Full body text omitted from this summary view._ Fetch the complete paper as Markdown: https://tomesphere.com/paper/1904.01287/full.md

## Figures

15 figures with captions in the complete paper: https://tomesphere.com/paper/1904.01287/full.md

## References

33 references — full list in the complete paper: https://tomesphere.com/paper/1904.01287/full.md

---
Source: https://tomesphere.com/paper/1904.01287