Abstract
GHC’s rewrite rules enable programmers to write local program transformation rules for their own functions. The most notable use case are fusion optimizations, which merge multiple traversals of a data structure into one and avoids allocation of intermediate structures. However, GHC’s rewrite rules were too limited to express a rewrite rule that is necessary for proper fusion of the concatMap function in a variant of fusion called stream fusion. We introduce higher order patterns as a simple extension of GHC’s rewrite rules. Higher order patterns substantially broaden the expressiveness of rewrite rules that involve local variables. In particular, they enable the rewriting of concatMap such that it can be properly optimized. We implement a stream fusion framework to replace the existing fusion framework in GHC and evaluate it on GHC’s benchmark suite. Our stream fusion framework with higher order patterns shows an average speedup of 7% compared to our stream fusion framework without it. However, our stream fusion framework is not yet able to match the performance of GHC’s existing fusion framework. Additionally, we show that our higher order patterns can be used to simplify GHC’s existing mechanism for rolling back failed attempts at fusion and, at the same time, solve a problem that prevented proper optimization in one example program. However, evaluating it on GHC’s benchmark suite shows a small regression in performance overall.
| Original language | English |
|---|---|
| Title of host publication | Haskell 2024 |
| Subtitle of host publication | Proceedings of the 17th ACM SIGPLAN International Haskell Symposium |
| Editors | Niki Vazou, J. Garrett Morris |
| Place of Publication | New York, NY |
| Publisher | Association for Computing Machinery (ACM) |
| Pages | 14-26 |
| Number of pages | 13 |
| ISBN (Electronic) | 9798400711022 |
| DOIs | |
| Publication status | Published - 2024 |
| Event | 17th ACM SIGPLAN International Symposium on Haskell - Milan, Italy Duration: 6 Sept 2024 → 7 Sept 2024 https://icfp24.sigplan.org/home/haskellsymp-2024 |
Conference
| Conference | 17th ACM SIGPLAN International Symposium on Haskell |
|---|---|
| Country/Territory | Italy |
| City | Milan |
| Period | 6/09/24 → 7/09/24 |
| Internet address |
Keywords
- Fusion
- GHC
- Haskell
- Higher Order Matching
- Optimization
- Program Transformation
- Rewrite Rules
Fingerprint
Dive into the research topics of 'Higher Order Patterns for Rewrite Rules'. Together they form a unique fingerprint.Cite this
- APA
- Author
- BIBTEX
- Harvard
- Standard
- RIS
- Vancouver