First-Order Laziness
Files
Publication date
2025-08-05
Editors
Advisors
Supervisors
Document Type
Article
Metadata
Show full item recordCollections
License
cc_by
Abstract
In strict languages, laziness is typically modeled with explicit thunks that defer a computation until needed and memoize the result. Such thunks are implemented using a closure. Implementing lazy data structures using thunks thus has several disadvantages: closures cannot be printed or inspected during debugging; allocating closures requires additional memory, sometimes leading to poor performance; reasoning about the performance of such lazy data structures is notoriously subtle. These complications prevent wider adoption of lazy data structures, even in settings where they should shine. In this paper, we introduce lazy constructors as a simple first-order alternative to lazy thunks. Lazy constructors enable the thunks of a lazy data structure to be defunctionalized, yielding implementations of lazy data structures that are not only significantly faster but can easily be inspected for debugging.
Keywords
Defunctionalization, Laziness, Perceus, Software, Safety, Risk, Reliability and Quality
Citation
Lorenzen, A, Leijen, D, Swierstra, W & Lindley, S 2025, 'First-Order Laziness', Proceedings of the ACM on Programming Languages, vol. 9, no. ICFP, pp. 734-762. https://doi.org/10.1145/3747530