paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Reasoning about effect interaction by fusion

通过融合推理效应交互
ICFP 5(ICFP)2021匹配度 1/10 · 该论文属于函数式编程与形式语义领域,研究 effect handlers 的组合语义,与用户关注的 PL→AI、AI→PL、浮点程序分析、贝叶斯程序分析及 LLM 交叉方向均无直接关联;虽涉及形式化方法,但未结合机器学习、Agent 或静态分析工具。引用 9 inbox
Zhixuan Yang, Nicolas Wu
crossref: 2026-09-10

AI 速览

一句话:提出用 fold/build 融合与 CPS 变换推导效应处理器组合的充分条件,以判定复合处理器语义。

效应处理器按顺序组合时,每个处理器只处理部分操作,但复合语义对顺序敏感,确定正确顺序困难。本文提出系统方法,用 fold/build 融合与 CPS 变换将两个处理器融合为一个,仅由相关操作子句推导复合处理器正确处理效应理论之和、张量组合的充分条件。案例研究覆盖交换与分配交互,得到:处理器遵守的等式在组合后保持;先处理可变状态可使其操作与后续处理器操作交换;writer 效应与可变状态按任一顺序处理均得到交换组合的正确处理器。

问题
效应处理器顺序组合的语义对组合顺序敏感,如何确定正确组合顺序及复合处理器是否保持各效应理论交互性质是难题。
方法
提出用 fold/build 融合和 CPS 变换把两个处理器融合成一个,由相关操作子句推导复合处理器正确处理效应理论之和/张量组合的充分条件。
评估
通过交换与分配交互的案例研究,验证该条件可推出等式保持、状态操作交换及 writer 与可变状态组合正确等常见处理器结论。
原文摘要(Abstract)

Effect handlers can be composed by applying them sequentially, each handling some operations and leaving other operations uninterpreted in the syntax tree. However, the semantics of composed handlers can be subtle---it is well known that different orders of composing handlers can lead to drastically different semantics. Determining the correct order of composition is a non-trivial task. To alleviate this problem, this paper presents a systematic way of deriving sufficient conditions on handlers for their composite to correctly handle combinations, such as the sum and the tensor, of the effect theories separately handled. These conditions are solely characterised by the clauses for relevant operations of the handlers, and are derived by fusing two handlers into one using a form of fold/build fusion and continuation-passing style transformation. As case studies, the technique is applied to commutative and distributive interaction of handlers to obtain a series of results about the interaction of common handlers: (a) equations respected by each handler are preserved after handler composition; (b) handling mutable state before any handler gives rise to a semantics in which state operations are commutative with any operations from the latter handler; (c) handling the writer effect and mutable state in either order gives rise to a correct handler of the commutative combination of these two theories.

链接与引用

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

BibTeX
@article{paperbot1107,
  title = {Reasoning about effect interaction by fusion},
  author = {Zhixuan Yang and Nicolas Wu},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {5},
  number = {ICFP},
  year = {2021},
  doi = {10.1145/3473578}
}