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.


翻译:一种有前景的统一函数式与命令式编程范式的方法是通过线性或仿射类型局部化可变性。Haskell作为一种纯函数式语言,近期由Bernardy等人以Linear Haskell之名扩展了线性类型。然而,尚不清楚这种纯语言能否安全地支持Rust风格的非局部借用——其中每个借用者可自由拆分与丢弃,无需向出借者直接通讯所有权。我们通过Pure Borrow(一种在Linear Haskell中实现Rust风格借用并保持纯度的新型框架)对此问题给出肯定回答。值得注意的是,该框架在纯计算内部实现了带仿射可变引用的并行状态可变性,不同于IO与ST单子及现有Linear Haskell API。与Rust不同,它兼具纯度、惰性求值、一等多态性与无泄漏特性。我们将Pure Borrow简单实现为Linear Haskell库,并通过并行计算案例研究展示其能力。我们形式化了Pure Borrow的核心机制,并建立元理论以通过基于借用历史的新模型来论证安全性、无泄漏性与合流性。

0
下载
关闭预览

相关内容

专知会员服务
79+阅读 · 2021年3月16日
【经典书】线性代数,399页pdf,Georgi Shilov经典本科教材
【经典书】线性代数,Linear Algebra,525页pdf
专知会员服务
79+阅读 · 2021年1月29日
【经典书】线性代数,352页pdf教你应该这样学
专知会员服务
107+阅读 · 2020年12月20日
一文读懂线性回归、岭回归和Lasso回归
CSDN
34+阅读 · 2019年10月13日
那些值得推荐和收藏的线性代数学习资源
放弃 RNN/LSTM 吧,因为真的不好用!望周知~
人工智能头条
19+阅读 · 2018年4月24日
线性回归:简单线性回归详解
专知
12+阅读 · 2018年3月10日
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
6+阅读 · 2017年6月30日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
Arxiv
0+阅读 · 4月23日
VIP会员
相关主题
最新内容
驱动军事决策变革的顶尖人工智能指挥系统
专知会员服务
8+阅读 · 8月11日
非对称防御中的自组织临界性:俄乌战争
专知会员服务
10+阅读 · 8月10日
《战争中的大语言模型监管》
专知会员服务
14+阅读 · 8月10日
《边缘计算关键技术分析及美军作战实践应用》
边缘计算的军事应用
专知会员服务
12+阅读 · 8月9日
一种考虑资源机动性的武器目标分配混合算法
专知会员服务
13+阅读 · 8月8日
相关基金
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
6+阅读 · 2017年6月30日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员