arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1904.01287cs.PLcs.SE
收藏

具有静态线性的多方会话类型安全Web开发

Multiparty Session Type-safe Web Development with Static Linearity

Jonathan King, Nicholas Ng, Nobuko Yoshida

摘要:

现代Web应用程序现在可以在浏览器内提供类似桌面的体验,这要归功于WebSockets等技术,这些技术可以在浏览器和服务器之间实现低延迟双工通信。虽然这些进步对用户体验来说是巨大的,但它们代表了Web开发人员的新责任,他们现在需要管理和验证应用程序中更复杂和可能有状态的交互的正确性。在本文中,我们提出了一种技术,用于开发交互式Web应用程序,静态保证通信遵循给定的协议。首先,用Scribble协议语言描述全局交互协议--基于多方会话类型。Scribble协议被检查为格式良好,然后每个角色被投射到一个有限状态机,从角色的角度表示通信的结构。我们使用源代码生成和一种新的类型级编码的FSM使用多参数类型类,以利用类型系统的目标语言,并保证只有程序的通信协议将类型检查。我们的工作目标是PureScript --一种编译为JavaScript的函数式语言--它具有足够的表达能力来提供静态线性保证。我们证明了我们的方法的有效性,通过基于Web的战舰游戏,通过WebSocket连接进行通信。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑