一句话:将分数权限与分级类型结合,使 Rust 式所有权和借用平滑融入支持线性、分级类型的函数式类型系统。
Rust 式所有权与借用能在无需 GC 的情况下保证内存安全,但其类型系统与所有权模型在编译阶段相对分离,且如何将其基本思想融入更传统的类型系统仍缺乏简洁核心。本文提出以分数唯一性统一所有权、借用、线性与分级类型:将分数权限与 grading 结合,把唯一性视为可分级推广,从而在标准类型系统中自然导出类似 Rust 的所有权模型,并保持与线性类型和分级类型的兼容。作者进一步将该设计扩展到 Granule 语言,给出首个能平滑整合所有权与借用、线性与分级类型的方案,使函数式语言可以借鉴 Rust 等所有权框架的概念。
Ownership and borrowing systems, designed to enforce safe memory management without the need for garbage collection, have been brought to the fore by the Rust programming language. Rust also aims to bring some guarantees offered by functional programming into the realm of performant systems code, but the type system is largely separate from the ownership model, with type and borrow checking happening in separate compilation phases. Recent models such as RustBelt and Oxide aim to formalise Rust in depth, but there is less focus on integrating the basic ideas into more traditional type systems. An approach designed to expose an essential core for ownership and borrowing would open the door for functional languages to borrow concepts found in Rust and other ownership frameworks, so that more programmers can enjoy their benefits. One strategy for managing memory in a functional setting is through uniqueness types, but these offer a coarse-grained view: either a value has exactly one reference, and can be mutated safely, or it cannot, since other references may exist. Recent work demonstrates that linear and uniqueness types can be combined in a single system to offer restrictions on program behaviour and guarantees about memory usage. We develop this connection further, showing that just as graded type systems like those of Granule and Idris generalise linearity, a Rust-like ownership model arises as a graded generalisation of uniqueness. We combine fractional permissions with grading to give the first account of ownership and borrowing that smoothly integrates into a standard type system alongside linearity and graded types, and extend Granule accordingly with these ideas.
@article{paperbot2555,
title = {Functional Ownership through Fractional Uniqueness},
author = {Daniel Marshall and Dominic Orchard},
journal = {Proceedings of the ACM on Programming Languages},
volume = {8},
number = {OOPSLA1},
year = {2024},
doi = {10.1145/3649848}
}