纯借:线性Haskell与Rust风格的借阅
Pure Borrow: Linear Haskell Meets Rust-Style Borrowing
AI总结:
Pure Borrow在Linear Haskell中实现了Rust风格的借阅,支持纯计算中的并行状态突变,保留了纯性、惰性求值、多态性和无泄漏特性,通过案例研究展示了其在并行计算中的应用。
摘要:
一种统一函数式和命令式编程范式的有希望的方法是通过线性或仿射类型局部化突变。Haskell,一种纯粹的功能性语言,最近被Bernardy等人扩展了线性类型,称为线性Haskell。然而,不清楚这样的纯粹语言能否安全地支持非局部借阅,如Rust风格,其中每个借款人可以自由分割和丢弃,而无需直接将所有权通知回贷方。我们通过Pure Borrow,一种新的框架,确认了这一点,该框架在Linear Haskell中实现了Rust风格的借阅。值得注意的是,它在纯计算中实现了仿射可变引用的并行状态突变,不同于IO和ST monad以及现有的Linear Haskell API。它还享有纯性、惰性求值、一等多态性和无泄漏,不同于Rust。我们简单地在Linear Haskell中将Pure Borrow实现为一个库,并通过并行计算的案例研究展示了其威力。我们正式化了Pure Borrow的核心,并构建了一个理论,旨在建立安全性、无泄漏和连贯性,以及一个新的基于历史的借阅模型。
英文摘要:
A promising approach to unifying functional and imperative programming paradigms is to localize mutation using linear or affine types. Haskell, a purely functional language, was recently extended with linear types by Bernardy et al., in the name of Linear Haskell. However, it remained unknown whether such a pure language could safely support non-local borrowing in the style of Rust, where each borrower can be freely split and dropped without direct communication of ownership back to the lender. We answer this question affirmatively with Pure Borrow, a novel framework that realizes Rust-style borrowing in Linear Haskell with purity. Notably, it features parallel state mutation with affine mutable references inside pure computation, unlike the IO and ST monads and existing Linear Haskell APIs. It also enjoys purity, lazy evaluation, first-class polymorphism and leak freedom, unlike Rust. We implement Pure Borrow simply as a library in Linear Haskell and demonstrate its power with a case study in parallel computing. We formalize the core of Pure Borrow and build a metatheory that works toward establishing safety, leak freedom and confluence, with a new, history-based model of borrowing.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。