paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Intrinsically Typed Sessions with Callbacks (Functional Pearl)

带回调的内在类型化会话(Functional Pearl)
ICFP 7(ICFP)2023匹配度 2/10 · 该论文属于会话类型、线性类型与嵌入式DSL的形式化实现,虽与程序语言和形式验证相关,但未涉及LLM/Agent、机器学习系统静态分析、浮点程序分析或贝叶斯程序分析,与用户当前核心研究方向交集很小。引用 0 inbox
Peter Thiemann
crossref: 2026-09-10

AI 速览

一句话:提出基于回调/控制反转的嵌入式会话类型实现,使应用代码内在类型化、无法破坏线性性,并扩展到分支、递归、多通道等。

会话类型的可靠实现通常依赖线性类型,因为通道在每次操作后类型都会变化。已有嵌入式实现要么用复杂类型构造静态保证线性,要么用运行时检查近似线性。本文提出一种受控制反转启发的语言嵌入式会话类型实现:所有应用代码按构造即内在会话类型化,无法破坏线性性;线性性证明被封装在小型库中,只需在构建库时一次性完成。该设计可扩展到分支、递归、多通道、高阶会话以及上下文无关会话;多通道扩展还能按构造保证无死锁。工作由类型检查通过的 Agda 代码完整支撑。

问题
会话类型的嵌入式实现难以在不牺牲可靠性的情况下保证线性性与无死锁;现有方案依赖复杂静态类型构造或运行时近似检查。
方法
采用控制反转/回调风格,把线性性证明封装在小库中,使应用程序按构造成为内在会话类型化;并用 Agda 进行机器化验证。
评估
通过类型检查的 Agda 代码覆盖分支、递归、多通道、高阶与上下文无关会话,并论证多通道扩展按构造保证无死锁。
原文摘要(Abstract)

All formalizations of session types rely on linear types for soundness as session-typed communication channels must change their type at every operation. Embedded language implementations of session types follow suit. They either rely on clever typing constructions to guarantee linearity statically, or on run-time checks that approximate linearity. We present a new language-embedded implementation of session types, which is inspired by the inversion-of-control design principle. With our approach, all application programs are intrinsically session-typed and unable to break linearity by construction. Our design relies on a tiny encapsulated library, for which linearity remains a proof obligation that can be discharged once and for all when the library is built. We demonstrate that our proposed design extends to a wide range of features of session type systems: branching, recursion, multichannel and higher-order sessions, as well as context-free sessions. The multichannel extension provides an embedded implementation of session types which guarantees deadlock freedom by construction. The development reported in this paper is fully backed by type-checked Agda code.

链接与引用

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

BibTeX
@article{paperbot1932,
  title = {Intrinsically Typed Sessions with Callbacks (Functional Pearl)},
  author = {Peter Thiemann},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {7},
  number = {ICFP},
  year = {2023},
  doi = {10.1145/3607854}
}