I’m very proud to announce that “Lazy Linearity for a Core Functional Language”, a paper by myself and Bernardo Toninho, will be published at POPL 26!
The extended version of the paper, which includes all proofs, is available here [arXiv, PDF].
The short-ish story: In 2023, for my Master’s thesis, I reached out to Arnaud Spiwack to discuss how Linear Types had been implemented in GHC. I wanted to research compiler optimisations made possible by linearity. Arnaud was quick to tell me:
“Well yes, but you can’t!“
“Even though Haskell is linearly typed, Core isn’t!”1
Linearity is ignored in Core because, as soon as it’s optimised, previously valid linear programs become invalid. It turns out that traditional linear type systems are too syntactic, or strict, about understanding linearity – but Haskell, regardless of linear types, is lazily evaluated. Improving optimisations would have to wait.
Our paper presents a system which, in contrast, also accepts programs that can only be understood as linear under non-strict evaluation. Including the vast majority of optimised linear Core programs (with proofs!).
The key ideas of this paper were developed during my Master’s, but it took a few more years of on-and-off work (supported by my employer Well-Typed) with Bernardo to crystalize the understanding of a “lazy linearity” and strengthen the theoretical results.
Now, the proof of the pudding is in the eating. Go read it!
Abstract
Core is the
intermediate compiler language to which source Haskell is desugared and to
which optimisations are applied↩︎