paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Linearly qualified types: generic inference for capabilities and uniqueness

线性限定类型:能力与唯一性的通用推断
ICFP 6(ICFP)2022匹配度 2/10 · 论文属于线性类型系统与编译器约束求解/推断,偏向 PL 类型理论,与用户关注的 PL→AI(ML/Agentic 程序静态分析)、AI→PL(LLM 改进静态分析/形式化验证)、浮点程序分析及贝叶斯程序分析均无直接交叉。引用 6 inbox
Arnaud Spiwack, Csongor Kiss, Jean-Philippe Bernardy, Nicolas Wu, Richard A. Eisenberg
crossref: 2026-09-10

AI 速览

一句话:提出线性约束,把隐式线性参数作为限定类型,扩展 GHC 约束求解器自动推断,降低 Linear Haskell 使用负担。

线性类型可确保文件句柄、手动管理内存等资源被安全使用:线性参数必须在其函数体中被恰好消费一次。然而,显式书写线性参数会带来大量样板与官僚式负担。本文提出 linear constraints(线性约束),一种面向线性类型的前端特性:它们是隐式线性参数,由编译器自动填充。作者将线性约束形式化为一种 qualified type system(限定类型系统),并给出推断算法,该算法扩展了 GHC 现有的约束求解器。其可靠性(soundness)通过将线性约束脱糖(desugar)为 Linear Haskell 得到保证。该工作以 GHC/Linear Haskell 为背景,旨在让能力(capabilities)与唯一性(uniqueness)等资源使用更易表达,同时保持线性类型的安全性。

问题
显式线性参数虽能安全验证资源使用,但编写代码时需要大量样板,使用不便。
方法
提出 linear constraints 作为 qualified type system,将隐式线性参数交给编译器自动填充,并给出扩展 GHC 约束求解器的推断算法,通过脱糖到 Linear Haskell 保证 soundness。
评估
摘要未报告实验评估;正确性由到 Linear Haskell 的脱糖保证,推断实现扩展 GHC 现有约束求解器。
原文摘要(Abstract)

A linear parameter must be consumed exactly once in the body of its function. When declaring resources such as file handles and manually managed memory as linear arguments, a linear type system can verify that these resources are used safely. However, writing code with explicit linear arguments requires bureaucracy. This paper presents linear constraints, a front-end feature for linear typing that decreases the bureaucracy of working with linear types. Linear constraints are implicit linear arguments that are filled in automatically by the compiler. We present linear constraints as a qualified type system,together with an inference algorithm which extends GHC's existing constraint solver algorithm. Soundness of linear constraints is ensured by the fact that they desugar into Linear Haskell.

链接与引用

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

BibTeX
@article{paperbot1489,
  title = {Linearly qualified types: generic inference for capabilities and uniqueness},
  author = {Arnaud Spiwack and Csongor Kiss and Jean-Philippe Bernardy and Nicolas Wu and Richard A. Eisenberg},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {6},
  number = {ICFP},
  year = {2022},
  doi = {10.1145/3547626}
}