一句话:提出 ECMTT,用上下文模态类型内在地追踪代数效应,并把效应处理器视为上下文间可达性见证。
带代数效应的语言常用类型-效应系统追踪效应,但需在已有语言上附加效应标注。本文把计算的代数效应理论视为变量上下文,并用上下文模态类型追踪代数效应。作者定义新演算 ECMTT,以继承自上下文模态类型论(CMTT)的上下文化 □(必然)算子管理效应;效应标注内在于语言,由对应 □ 模态的引入/消去构造管理,故其类型-效应系统实际只是类型系统。ECMTT 具有局部可靠性与完备性,操作语义由 β-规约确定;效应处理器成为上下文(代数理论)间可达性的见证,推广了显式替换。这是首个将代数效应与模态类型联系的工作,并为借用模态逻辑/类型论结果的 Curry-Howard 对应迈出一步。
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 contextual modal types . We develop ECMTT, a novel calculus which tracks algebraic effects by a contextualized variant of the modal □ (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 □ 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.
@article{paperbot1134,
title = {Contextual modal types for algebraic effects and handlers},
author = {Nikita Zyuzin and Aleksandar Nanevski},
journal = {Proceedings of the ACM on Programming Languages},
volume = {5},
number = {ICFP},
year = {2021},
doi = {10.1145/3473580}
}