arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 1710.10385cs.PL
收藏

通过回放过去来捕捉未来

Capturing the Future by Replaying the Past

James Koppel, Gabriel Scherer, Armando Solar-Lezama

摘要:

有界延续是所有单子之母!Filinski在1994年的论文中提出的口号也是如此,该论文表明定界延续可以实现任何一元效果,让程序员可以像使用语言一样轻松地使用效果。遗憾的是,没有多少语言有分隔的延续。幸运的是,异常和状态也是所有单子之母!在这篇Pearl中,我们展示了如何根据异常和状态来实现定界的延续,我们称之为$\textit{thermometer continuations}$。虽然定界延续的传统实现需要某种方式来“捕获”计算的中间状态,但温度计延续的洞察力是通过从一开始就重播整个计算来达到这个中间状态,使用记录来引导它,以便在捕获点之前发生相同的事情。一路上,我们解释定界延续和一元反射,显示如何Filinski建设让温度计延续表示任何一元效应,共享一个优雅的特殊情况下,非决定性,并讨论为什么我们的建设是不阻止理论结果,例外和国家不能宏观表达延续。

英文摘要:

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 $\textit{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 it 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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑