Abstract
We present purity reflection, a programming language feature that enables higher-order functions to inspect the purity of their function arguments and to vary their behavior based on this information. The upshot is that operations on data structures can selectively use lazy and/or parallel evaluation while ensuring that side effects are never lost or re-ordered. The technique builds on a recent Hindley-Milner style type and effect system based on Boolean unification which supports both effect polymorphism and complete type inference. We illustrate that avoiding the so-called 'poisoning problem' is crucial to support purity reflection.
We propose several new data structures that use purity reflection to switch between eager and lazy, sequential and parallel evaluation. We propose a DelayList, which is maximally lazy but switches to eager evaluation for impure operations. We also propose a DelayMap which is maximally lazy in its values, but also exploits eager and parallel evaluation.
We implement purity reflection as an extension of the Flix programming language. We present a new effect-aware form of monomorphization that eliminates purity reflection at compile-time. And finally, we evaluate the cost of this new monomorphization on compilation time and on code size, and determine that it is minimal.
We propose several new data structures that use purity reflection to switch between eager and lazy, sequential and parallel evaluation. We propose a DelayList, which is maximally lazy but switches to eager evaluation for impure operations. We also propose a DelayMap which is maximally lazy in its values, but also exploits eager and parallel evaluation.
We implement purity reflection as an extension of the Flix programming language. We present a new effect-aware form of monomorphization that eliminates purity reflection at compile-time. And finally, we evaluate the cost of this new monomorphization on compilation time and on code size, and determine that it is minimal.
Original language | English |
---|---|
Title of host publication | 37th European Conference on Object-Oriented Programming (ECOOP 2023) |
Editors | Karim Ali, Guido Salvaneschi |
Number of pages | 27 |
Publisher | Dagstuhl Publishing |
Publication date | Jul 2023 |
Article number | 18 |
ISBN (Print) | 978-3-95977-281-5 |
ISBN (Electronic) | 9783959772815 |
DOIs | |
Publication status | Published - Jul 2023 |
Event | 37th European Conference on Object-Oriented Programming, ECOOP 2023 - Seattle, United States Duration: 17 Jul 2023 → 21 Jul 2023 |
Conference
Conference | 37th European Conference on Object-Oriented Programming, ECOOP 2023 |
---|---|
Country/Territory | United States |
City | Seattle |
Period | 17/07/2023 → 21/07/2023 |
Series | Leibniz International Proceedings in Informatics |
---|---|
Volume | 263 |
ISSN | 1868-8969 |
Keywords
- type and effect systems
- purity reflection
- lazy evaluation
- parallel evaluation