Programming languages with algebraic effects often rely on effect annotations to track algebraic operations in a computation. This is particularly important in the presence of effect handlers, where handling of an effect may remove it from the annotation in the computation's type. In this paper we view the algebraic effect theory of a computation as a variable context, and track the effects directly in computation's modal type with ECMTT, a novel calculus for algebraic effects and handlers. Our calculus supports computations with effects and derives from Contextual Modal Type Theory (CMTT), from which it inherits a number of important logical properties. In contrast to type-and-effect systems, where effects are attached as annotations to a prior computational language, ECMMT tracks effects by a contextualized variant of the modal $\Box$ (necessity) operator of the intuitionistic modal logic of CMTT. In programming, the effect annotations are explicitly managed by the dedicated term constructors corresponding to the logical introduction and elimination forms for the modality. The modal foundation leads to customary logical properties of local soundness and completeness, and determines the operational semantics of ECMTT directly by $\beta$-reduction. In addition, effect handlers become a generalization of explicit substitutions, which in CMTT serve to reach one context from another. 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.
翻译:具有代数效果的编程语言往往依赖效果说明来跟踪计算中的代数操作。 这在效果处理器的存在中特别重要, 效果处理可以将效果从计算类型中的批注中去除。 在本文中, 我们将计算结果的代数效应理论视为变量背景, 直接跟踪计算模式类型的影响, 与 ECMTT 是一种用于代数效应和处理者的新型计算计算。 我们的计算效果支持效果的计算, 并来自Conteracial Modal 类型( CMTT), 它从中继承了一些重要的逻辑属性。 与类型和效果系统相比, 将效果作为先前计算语言的批注, ECMT 跟踪效果, 由计算模型的缩略式模式( QMTT) 和处理器的缩略图( QMTF) 的缩略图( CMTF), 其效果由专门的术语构建者明确管理, 与该模式的逻辑引入和删除格式的表格。 模式的缩略图基础, 将Oralalalalalalalalal moal model model model moal moal model model model le del le del 和 del del del ex ex 。