特殊投递:基于邮箱类型的编程(扩展版)
Special Delivery: Programming with Mailbox Types (Extended Version)
AI总结:
本文提出了一种基于邮箱类型的新型行为类型系统,用于检测Actor语言中的通信错误,并通过Pat语言展示了其在实际应用中的表达能力。
摘要:
邮箱支持的异步和单向通信模型是Actor语言如Erlang和Elixir在实现可靠和可扩展的分布式系统方面取得成功的关键原因。尽管Actor消除了许多共享内存并发的问题,但仍容易受到通信错误如协议违规和死锁的影响。行为类型使得在开发过程中可以检测通信错误,但大多数工作都是针对基于通道的语言而非Actor语言。邮箱类型是一种新的行为类型系统,首次在过程算符中引入,将邮箱内容表示为可交换的正则表达式。由于别名和嵌套评估上下文,从过程算符到编程语言的转换具有挑战性。本文提出了Pat,这是第一个包含邮箱类型的编程语言,并描述了算法类型系统。Pat是一种高阶函数语言,具有sum、product和list,以及允许更细致地推理邮箱内容的接口。在Pat中进行类型检查可以检测四种类别的行为错误:协议违规、意外消息、遗忘回复和自死锁,以及通常的数据类型错误。Pat类型系统关键地使用了准线性类型来缓解别名引入的复杂性。我们通过一种新颖的向后双向类型使用,实现了共上下文算法类型系统,并证明了它在声明性类型系统中的正确性和完备性。我们实现了类型检查器,并使用它在工厂自动化案例研究和Savina actor基准套件的一系列示例中展示了Pat的表达能力。这为将邮箱类型应用于实际Actor语言奠定了基础。
英文摘要:
The asynchronous and unidirectional communication model supported by mailboxes is a key reason for the success of actor languages like Erlang and Elixir for implementing reliable and scalable distributed systems. Although actors eliminate many of the issues stemming from shared memory concurrency, they remain vulnerable to communication errors such as protocol violations and deadlocks. Behavioural types make it possible to detect communication errors early in the development process, but most work has addressed channel-based languages rather than actor languages. Mailbox types are a novel behavioural type system for actors first introduced for a process calculus, and capture the contents of a mailbox as a commutative regular expression. Due to aliasing and nested evaluation contexts, moving from a process calculus to a programming language is challenging. This paper presents Pat, the first programming language incorporating mailbox types, and describes an algorithmic type system. Pat is a higher-order functional language with sums, products, and lists, along with interfaces that allow finer-grained reasoning about mailbox contents. Typechecking in Pat detects four classes of behavioural error: protocol violation, unexpected message, forgotten reply and self-deadlock, as well as the usual data type errors. The Pat type system makes essential use of quasi-linear typing to tame some of the complexity introduced by aliasing. We make use of a co-contextual algorithmic type system, achieved through a novel use of backwards bidirectional typing, and we prove it sound and complete with respect to our declarative type system. We implement a type checker, and use it to demonstrate the expressiveness of Pat on a factory automation case study and a series of examples from the Savina actor benchmark suite. This establishes a foundation for applying mailbox typing to practical actor languages.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。