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., named Linear Haskell. However, it remained unknown whether such a pure language could safely support non-local \emph{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 by \emph{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
下载
关闭预览

相关内容

如何用latext画神经网络?这个PlotNeuralNet能帮到你
专知会员服务
26+阅读 · 2022年1月15日
【经典书】线性代数,Linear Algebra,525页pdf
专知会员服务
79+阅读 · 2021年1月29日
那些值得推荐和收藏的线性代数学习资源
从 Word Embedding 到 Bert:一起肢解 Bert!
人工智能头条
17+阅读 · 2018年12月11日
放弃 RNN/LSTM 吧,因为真的不好用!望周知~
人工智能头条
19+阅读 · 2018年4月24日
最新|深度离散哈希算法,可用于图像检索!
全球人工智能
14+阅读 · 2017年12月15日
国家自然科学基金
6+阅读 · 2017年6月30日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
Arxiv
0+阅读 · 4月23日
VIP会员
相关主题
最新内容
综述 | 从问答到任务完成:Agent系统与Harness设计
Agentic RL:框架、实践与长程智能体训练
专知会员服务
2+阅读 · 6月24日
重新思考无人机时代的生存能力
专知会员服务
6+阅读 · 6月24日
装甲突击旅:现代战争思考、战斗与组织
专知会员服务
5+阅读 · 6月24日
在人工智能加速决策环境中拓展OODA循环
专知会员服务
5+阅读 · 6月24日
军事欺骗:供作战战术指挥官使用的工具
专知会员服务
5+阅读 · 6月24日
综述 | 世界动作模型:少做梦,多行动
专知会员服务
7+阅读 · 6月23日
美以伊冲突:无人机与人工智能的运用
专知会员服务
10+阅读 · 6月23日
《特种部队在透明战场中的生存力》最新报告
专知会员服务
5+阅读 · 6月23日
相关基金
国家自然科学基金
6+阅读 · 2017年6月30日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
3+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员