The Long Way to Deforestation (Technical Report): A Type Inference and Elaboration Technique for Removing Intermediate Data Structures
Yijia Chen, Lionel Parreaux

TL;DR
Lumberhack introduces a novel subtype inference and elaboration technique for deforestation in functional programs, enabling efficient removal of intermediate data structures and achieving significant performance improvements.
Contribution
It presents Lumberhack, a general-purpose deforestation method that fuses recursive definitions in call-by-value functional programs using subtype inference.
Findings
Achieves significant speedups in benchmark tests
Fuses large classes of recursive definitions effectively
Avoids excessive code duplication
Abstract
Deforestation is a compiler optimization that removes intermediate data structure allocations from functional programs to improve their efficiency. This is an old idea, but previous approaches have proved limited or impractical: they either only worked on compositions of predefined combinators (shortcut fusion), or involved the aggressive unfolding of recursive definitions until a depth limit was reached or a reoccurring pattern was found to tie the recursive knot, resulting in impractical algorithmic complexity and large amounts of code duplication. We present Lumberhack, a general-purpose deforestation approach for purely functional call-by-value programs. Lumberhack uses subtype inference to reason about data structure production and consumption and uses an elaboration pass to fuse the corresponding recursive definitions. It fuses large classes of mutually recursive definitions while…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
