Lazy Intermediate Representations for Algebraic Effects
Simon Castellan, Hugo Paquet
Abstract
A lazy program interpreter postpones computation until the result is actually needed. This is typically more efficient than an eager (or call-by-value) interpreter, but a concern is that the semantics is not generally preserved.
We propose a new semantic analysis of lazy evaluation that relies on a subtle combination of name generation and read-only state. Our perspective is that laziness arises from a hybrid evaluation strategy, in which only the name generation follows call-by-value.
This semantic model suggests better intermediate representations of sum and product types in a lazy interpreter, along with equations that justify further optimizations. We illustrate this with an implementation in OCaml. Our motivation is practical: the origin of this work is a realworld application of discrete probabilistic programming, in which large algebraic data types cause significant performance issues with a call-by-value interpreter. Our lazy semantics justifies better optimized representations, and provides principled foundations for other methods involving laziness in probabilistic programming.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext f651117c-4ef3-4bf2-99a0-669e8f9ff354Builds on5
- Affine Monads and Lazy Structures for Bayesian ProgrammingSwaraj Dash, Younesse Kaddar, Hugo Paquet, Sam StatonPOPL 2023 · 12 citations
- Adequacy for Algebraic Effects RevisitedG. A. KavvosOOPSLA 2025 · 6 citations
- Roulette: A Language for Expressive, Exact, and Efficient Discrete Probabilistic ProgrammingCameron Moy, Jack Czenszak, John M. Li, Brianna Marshall et al.PLDI 2025 · 3 citations
- Stochastic Lazy Knowledge Compilation for Inference in Discrete Probabilistic ProgramsMaddy Bowers, Alexander K. Lew, Joshua B. Tenenbaum, Armando Solar-Lezama et al.PLDI 2025 · 2 citations
- Categorical Semantics of Probabilistic Symbolic ExecutionJohn M. Li, Jack Czenszak, Steven HoltzenPLDI 2026
Related papers
- Exact Recursive Probabilistic ProgrammingDavid Chiang, Colin McDonald, Chung-chieh ShanOOPSLA 2023 · 12 citations
- Compiling Probabilistic Programs for Variable Elimination with Information FlowJianlin Li, Eric Wang, Yizhou ZhangPLDI 2024 · 6 citations
- Exact Bayesian Inference for Loopy Probabilistic Programs using Generating FunctionsLutz Klinkenberg, Christian Blumenthal, Mingshuai Chen, Darion Haase et al.OOPSLA 2024 · 11 citations
- Probabilistic programming semantics for name generationMarcin Sabok, Sam Staton, Dario Stein, Michael WolmanPOPL 2021 · 2 citations
- Semantics for variational Quantum programmingXiaodong Jia, Andre Kornell, Bert Lindenhovius, Michael W. Mislove et al.POPL 2022 · 15 citations
