paperbot · PL 论文追踪

全部论文 待读 收藏

P2 A Calculus for Scoped Effects & Handlers

Scoped Effects 与 Handlers 的演算
LMCS vol.Volume 20, Issue 42024匹配度 1/10 · 该论文属于纯程序语言理论,研究 scoped effects/handlers 的演算、类型-效应系统与类型推断,与用户关注的 ML/Agentic 程序静态分析、LLM 与静态分析/形式化验证结合、浮点程序分析或贝叶斯程序分析均无直接关联。仅在广义 PL 理论背景上可能有间接价值,但不匹配核心研究方向。引用 4 inbox
Roger Bosman, Birthe van den Berg, Wenhao Tang, Tom Schrijvers
crossref: 2026-09-10

AI 速览

一句话:提出原生支持代数与 scoped effects/handlers 的演算 λ_sc,含多态处理器、转发子句及类型-效应系统与推断。

代数效应与处理器已成为函数式编程中处理副作用的常用方案,但并非所有效应都是代数的:有界作用域(scoped)效应的续延分为作用域内、外两部分,模块化组合更复杂,现有演算尚缺乏对 scoped effects/handlers 的原生支持。本文提出 λ_sc,一个同时原生支持代数与 scoped 效应及处理器的演算,重点解决多态处理器和将未知 scoped 操作转发给其他处理器的显式子句问题。该演算基于 Eff,并扩展 Koka 风格的行多态,给出形式语法、操作语义、类型安全的类型-效应系统及类型推断。作者通过一系列例子展示其表达能力。

问题
如何为 scoped effects & handlers 提供与代数效应类似的演算支持,尤其处理有界作用域、续延分裂、多态处理器和模块化转发。
方法
提出 λ_sc,基于 Eff 并加入 Koka 风格行多态,原生支持代数与 scoped 效应/处理器,定义形式语法、操作语义、类型-效应系统与类型推断,含显式转发子句。
评估
通过一系列例子展示 λ_sc 的表达能力,包括代数与 scoped 效应、处理器组合及类型推断。
原文摘要(Abstract)

Algebraic effects & handlers have become a standard approach for side-effects in functional programming. Their modular composition with other effects and clean separation of syntax and semantics make them attractive to a wide audience. However, not all effects can be classified as algebraic; some need a more sophisticated handling. In particular, effects that have or create a delimited scope need special care, as their continuation consists of two parts-in and out of the scope-and their modular composition introduces additional complexity. These effects are called scoped and have gained attention by their growing applicability and adoption in popular libraries. While calculi have been designed with algebraic effects & handlers built in to facilitate their use, a calculus that supports scoped effects & handlers in a similar manner does not yet exist. This work fills this gap: we present $\lambda_{\mathit{sc}}$, a calculus with native support for both algebraic and scoped effects & handlers. It addresses the need for polymorphic handlers and explicit clauses for forwarding unknown scoped operations to other handlers. Our calculus is based on Eff, an existing calculus for algebraic effects, extended with Koka-style row polymorphism, and consists of a formal grammar, operational semantics, a (type-safe) type-and-effect system and type inference. We demonstrate $\lambda_{\mathit{sc}}$ on a range of examples.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot2705,
  title = {A Calculus for Scoped Effects & Handlers},
  author = {Roger Bosman and Birthe van den Berg and Wenhao Tang and Tom Schrijvers},
  journal = {Logical Methods in Computer Science},
  volume = {Volume 20, Issue 4},
  year = {2024},
  doi = {10.46298/lmcs-20(4:17)2024}
}