arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2604.21467cs.PL
收藏

线性约束

Linear Constraints

Imperial College London(伦敦帝国学院);University of Gothenburg(哥德堡大学)

Arnaud Spiwack, Csongor Kiss, Jean-Philippe Bernardy, Nicolas Wu, Richard A. Eisenberg

AI总结:

本文提出线性约束,通过隐式参数简化线性类型编程,提升资源管理安全性,扩展GHC求解器并改进形式系统。

摘要:

线性约束是Haskell类约束的线性对应物。线性类型参数允许程序员通过线性参数控制资源,如文件句柄和手动管理的内存。事实上,线性类型系统可以验证这些资源被安全使用。然而,编写显式线性参数的代码需要繁琐的步骤。线性约束解决了这一不足:线性约束作为隐式线性参数,可以由编译器自动填充。我们以限定类型系统的形式呈现这一新特性,并提供一个扩展GHC现有约束求解器算法的推断算法。线性约束的正确性由其转化为线性Haskell的事实保证。本文是同一作者之前论文(arXiv:2103.06127)的修订和扩展版本。形式系统和约束求解器已被显著简化,并描述了众多额外的应用。

英文摘要:

Linear constraints are the linear counterpart of Haskell's class constraints. Linearly typed parameters allow the programmer to control resources such as file handles and manually managed memory as linear arguments. Indeed, a linear type system can verify that these resources are used safely. However, writing code with explicit linear arguments requires bureaucracy. Linear constraints address this shortcoming: a linear constraint acts as an implicit linear argument that can be filled in automatically by the compiler. We present this new feature 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. This paper is a revised and extended version of a previous paper by the same authors (arXiv:2103.06127). The formal system and the constraint solver have been significantly simplified and numerous additional applications are described.

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

↑