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

代数效果和处理程序的上下文模态类型

Contextual Modal Types for Algebraic Effects and Handlers

Nikita Zyuzin, Aleksandar Nanevski

摘要:

具有代数效果的程序设计语言通常使用类型和效果系统来跟踪计算的效果。在本文中,我们建议将计算的代数效应理论视为变量上下文,因此,我们建议使用\emph{contextual modal types}跟踪计算的代数效应。我们开发ECMTT,一种新的演算,跟踪代数的影响,由一个上下文化的变体的模态$\Box$(必要性)运营商,它继承了上下文模态类型论(CMTT)。尽管类型和效果系统在现有程序设计语言之上添加效果注释,但ECMTT中的效果注释是该语言所固有的,因为它们由对应于$\Box$模态的逻辑引入和消除形式的编程构造来管理。因此,ECMTT的类型和效果制度实际上只是一种类型制度。我们的设计获得了本地的健全性和完整性的属性,并确定操作语义仅由$β$ -减少,在其他基于逻辑的演算习惯。在这种观点中,效果处理程序自然地出现,作为一个上下文(即,代数理论)可以从另一个达到,从CMTT推广显式替换。据我们所知,ECMTT是第一个将代数效应与模态类型联系起来的系统。我们也认为这是一个步骤,提供了一个符合风格的库里和霍华德,可能会转移一些结果领域的模态逻辑和模态类型论的代数效果。

英文摘要:

Programming languages with algebraic effects often track the computations' effects using type-and-effect systems. In this paper, we propose to view an algebraic effect theory of a computation as a variable context; consequently, we propose to track algebraic effects of a computation with \emph{contextual modal types}. We develop ECMTT, a novel calculus which tracks algebraic effects by a contextualized variant of the modal $\Box$ (necessity) operator, that it inherits from Contextual Modal Type Theory (CMTT). Whereas type-and-effect systems add effect annotations on top of a prior programming language, the effect annotations in ECMTT are inherent to the language, as they are managed by programming constructs corresponding to the logical introduction and elimination forms for the $\Box$ modality. Thus, the type-and-effect system of ECMTT is actually just a type system. Our design obtains the properties of local soundness and completeness, and determines the operational semantics solely by $β$-reduction, as customary in other logic-based calculi. In this view, effect handlers arise naturally as a witness that one context (i.e., algebraic theory) can be reached from another, generalizing explicit substitutions from CMTT. To the best of our knowledge, ECMTT is the first system to relate algebraic effects to modal types. We also see it as a step towards providing a correspondence in the style of Curry and Howard that may transfer a number of results from the fields of modal logic and modal type theory to that of algebraic effects.

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

↑