一句话:提出余单子类型纪律与能力空间模型,在带效应λ演算中用类型刻画纯表达式并保持等式推理。
论文研究如何在普遍带效应的 ML 风格类型化 λ 演算中重新刻画纯表达式。作者观察到,正如纯 STLC 可用单子类型纪律加入效应,带效应演算也可用余单子类型纪律加入纯性。为此提出能力空间模型,将执行效应需拥有运行时可访问能力/许可的直觉形式化,并定义能力安全。文章刻画该模型满足的范畴公理,给出余单子类型系统的范畴语义;为命令式 λ 演算建立含替换、按值调用 β/η 的等式理论并证明可靠性;最后把纯 STLC 翻译到该演算,证明 βη 相等项翻译后仍相等,从而保持等式地嵌入纯程序。
In this paper, we take a pervasively effectful (in the style of ML) typed lambda calculus, and show how to extend it to permit capturing pure expressions with types. Our key observation is that, just as the pure simply-typed lambda calculus can be extended to support effects with a monadic type discipline, an impure typed lambda calculus can be extended to support purity with a comonadic type discipline. We establish the correctness of our type system via a simple denotational model, which we call the capability space model. Our model formalises the intuition common to systems programmers that the ability to perform effects should be controlled via access to a permission or capability, and that a program is capability-safe if it performs no effects that it does not have a runtime capability for. We then identify the axiomatic categorical structure that the capability space model validates, and use these axioms to give a categorical semantics for our comonadic type system. We then give an equational theory (substitution and the call-by-value β and η laws) for the imperative lambda calculus, and show its soundness relative to this semantics. Finally, we give a translation of the pure simply-typed lambda calculus into our comonadic imperative calculus, and show that any two terms which are βη-equal in the STLC are equal in the equational theory of the comonadic calculus, establishing that pure programs can be mapped in an equation-preserving way into our imperative calculus.
DOI 原文 · arXiv · PDF(开放获取) · DBLP
@article{abs-1907-07283,
title = {Recovering purity with comonads and capabilities},
author = {Vikraman Choudhury and Neel Krishnaswami},
journal = {Proceedings of the ACM on Programming Languages},
volume = {4},
number = {ICFP},
year = {2020},
doi = {10.1145/3408993}
}