paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Capturing the future by replaying the past (functional pearl)

通过重放过去来捕获未来(函数式珍珠)
ICFP 2(ICFP)2018匹配度 1/10 · 该论文属于函数式编程与语言设计中的定界续体、monad 效果实现,与用户关注的 ML/Agentic 程序静态分析、LLM 与静态分析/形式化验证交叉、浮点程序分析或贝叶斯程序分析均无直接关联。引用 3 inbox
James Koppel, Gabriel Scherer, Armando Solar-Lezama
crossref: 2026-09-10

AI 速览

一句话:提出 thermometer continuations,用异常与状态从头重放计算来实现定界续体,并借此表达任意 monadic 效果。

定界续体常被视为“所有 monad 之母”,可统一实现任意 monadic 效果,但许多语言并不原生支持。本文展示如何仅用异常和状态实现定界续体,称为 thermometer continuations。传统实现需要捕获计算的中间状态;该方法则从程序开始重放整个计算,并借助一份记录引导重放,使其在到达被捕获点之前执行相同步骤,从而重建该中间状态。作者解释了定界续体与 monadic reflection,并利用 Filinski 构造证明 thermometer continuations 可表达任意 monadic 效果,还给出非确定性的优雅特例,并讨论为何“异常和状态不能宏表达续体”的理论结果不阻止该构造。

问题
许多语言缺少原生定界续体,却仍希望用它们以统一方式实现任意 monadic 效果;本文研究能否仅靠异常和状态实现定界续体。
方法
提出 thermometer continuations:不直接捕获中间状态,而是从程序开始重放整个计算,并用记录引导重放至被捕获点;再结合 Filinski 构造表达任意 monadic 效果。
评估
以构造性实现、定界续体与 monadic reflection 的解释、非确定性特例及与既有宏表达理论结果的讨论来论证方法。
原文摘要(Abstract)

Delimited continuations are the mother of all monads! So goes the slogan inspired by Filinski’s 1994 paper, which showed that delimited continuations can implement any monadic effect, letting the programmer use an effect as easily as if it was built into the language. It’s a shame that not many languages have delimited continuations. Luckily, exceptions and state are also the mother of all monads! In this Pearl, we show how to implement delimited continuations in terms of exceptions and state, a construction we call thermometer continuations . While traditional implementations of delimited continuations require some way of ”capturing” an intermediate state of the computation, the insight of thermometer continuations is to reach this intermediate state by replaying the entire computation from the start, guiding it using a recording so that the same thing happens until the captured point. Along the way, we explain delimited continuations and monadic reflection, show how the Filinski construction lets thermometer continuations express any monadic effect, share an elegant special-case for nondeterminism, and discuss why our construction is not prevented by theoretical results that exceptions and state cannot macro-express continuations.

链接与引用

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

BibTeX
@article{paperbot278,
  title = {Capturing the future by replaying the past (functional pearl)},
  author = {James Koppel and Gabriel Scherer and Armando Solar-Lezama},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {2},
  number = {ICFP},
  year = {2018},
  doi = {10.1145/3236771}
}