paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Effectful Lenses: There and Back with Different Monads

带效应的透镜:在不同 Monad 之间往返
ICFP 9(ICFP)2025匹配度 1/10 · 这篇论文属于函数式编程与双向变换/透镜理论,研究带效应 lens 的通用框架与往返性质,与用户关注的静态分析、LLM/Agent、浮点程序分析及贝叶斯程序分析均无直接关联。虽然同属 PL/形式化方向,但核心问题与用户当前研究画像差距很大。引用 1 inbox
Ruifeng Xie, Tom Schrijvers, Zhenjiang Hu
crossref: 2026-09-10

AI 速览

一句话:提出一个更通用的带效应透镜框架,两个方向可使用不同 Monad,并保持往返性质与组合性。

双向变换通常由 source→view 和 view→source 两个函数构成,传统上要求它们无副作用。已有将 Monad 引入透镜的框架限制较强,例如只允许后向变换产生效应。本文提出更通用的带效应透镜框架:两个方向可以具有不同效应,且效应无需可取消。作者定义往返关系,并据此将两个经典往返性质推广到带效应情形;证明组合保持这些性质,并提供丰富的组合子语言以支持带效应透镜的组合式编程。最后通过案例研究展示该框架的灵活性与表达力。

问题
传统双向变换假定两个方向无副作用,已有 monadic lens 限制较大,例如仅允许后向变换产生效应,难以表达两个方向具有不同效应的场景。
方法
提出带效应透镜框架,允许两个方向使用不同 Monad 且效应不可取消;定义往返关系以推广经典往返性质,并给出保持性质的组合机制与组合子语言。
评估
通过案例研究展示该框架在带效应双向变换中的灵活性与表达力。
原文摘要(Abstract)

Bidirectional transformations (BXs) are a widely adopted approach for data synchronisation that is usually based on two functions, one from the source to the view and one back. Traditionally, these functions must not have side effects. While a few frameworks aim to lift this restriction by introducing monads into lenses, they are still quite limited, e.g., allowing only side effects in the backwards transformation. In this paper, we propose a much more general framework for effectful lenses. Our effectful lenses can have different effects in their two directions, and the effects need not be cancellable. We also define the round-trip relations and use them to generalise the two well-known round-trip properties to effectful lenses. Moreover, composition preserves the two well-known round-trip properties, and we also provide a rich combinator language, which enables compositional programming for effectful lenses. Finally, we present a case study to illustrate the flexibility and expressivity of our framework.

链接与引用

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

BibTeX
@article{paperbot3046,
  title = {Effectful Lenses: There and Back with Different Monads},
  author = {Ruifeng Xie and Tom Schrijvers and Zhenjiang Hu},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {9},
  number = {ICFP},
  year = {2025},
  doi = {10.1145/3747523}
}