一句话:提出 Hefty 代数,将高阶操作的展开过程模块化,从而在不改接口、不重编译的情况下支持高阶代数效应的实现与精化。
代数效应与处理器因其模块性而流行:程序只依赖声明的操作接口,实现可独立定义和精化,无需修改或重编译程序。然而,接受计算作为参数的高阶操作会破坏这种模块性。已有做法把高阶操作精化为更原始效应与处理器,但这类精化通常不模块化,因为精化出的操作不属于任何效应接口。本文提出一种出乎意料简单的替代方案:将原本非模块化的高阶操作精化本身模块化,并为此引入 Hefty 代数。该方案在表达能力上达到效应与处理器领域最新工作的水平。
Algebraic effects and handlers is an increasingly popular approach to programming with effects. An attraction of the approach is its modularity: effectful programs are written against an interface of declared operations, which allows the implementation of these operations to be defined and refined without changing or recompiling programs written against the interface. However, higher-order operations (i.e., operations that take computations as arguments) break this modularity. While it is possible to encode higher-order operations by elaborating them into more primitive algebraic effects and handlers, such elaborations are typically not modular. In particular, operations defined by elaboration are typically not a part of any effect interface, so we cannot define and refine their implementation without changing or recompiling programs. To resolve this problem, a recent line of research focuses on developing new and improved effect handlers. In this paper we present a (surprisingly) simple alternative solution to the modularity problem with higher-order operations: we modularize the previously non-modular elaborations commonly used to encode higher-order operations. Our solution is as expressive as the state of the art in effects and handlers.
@article{paperbot2051,
title = {Hefty Algebras: Modular Elaboration of Higher-Order Algebraic Effects},
author = {Casper Bach Poulsen and Cas van der Rest},
journal = {Proceedings of the ACM on Programming Languages},
volume = {7},
number = {POPL},
year = {2023},
doi = {10.1145/3571255}
}