Fully-Automatic Type Inference for Borrows with Lifetimes

Authors:
William Brandon, Benjamin Driscoll, Frank Dai, Jonathan Ragan-Kelley, Mae Milano, Alex Aiken
Published:
Proceedings of the ACM on Programming Languages, volume 10, issue OOPSLA1, pp. 597-623. April 10, 2026.
Abstract:

We present a new pure functional language and type system with borrows with lifetimes, and a corresponding fully-automatic type inference procedure. Inference provides users the performance benefits of borrows with lifetimes without requiring user annotation. If the user's program cannot be typed, inference inserts a handful of reference count operations so that it can be typed. We provide a heap semantics for our borrowing language and prove a soundness theorem, guaranteeing that well-typed programs do not violate memory safety. We implement our memory management strategy as part of the Morphic language stack and compare it to Perceus, a state-of-the-art reference-counting technique based on linear type inference. We find that our system is able to eliminate almost all reference count operations across a range of programs, reducing reference count increments by 75-100% on all benchmarks with reference count increments under the baseline. As a result, we achieve a 1.48x geomean speedup overall on all benchmarks.

BibTeX:
@article{brandon2026,
  title = {{Fully-Automatic Type Inference for Borrows with Lifetimes}},
  author = {William Brandon and Benjamin Driscoll and Frank Dai and Jonathan Ragan-Kelley and Mae Milano and Alex Aiken},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {10},
  issue = {OOPSLA1},
  year = 2026,
  month = 4,
  day = 10,
  doi = {10.1145/3798221},
}