Skip to main navigation Skip to search Skip to main content

Higher Order Patterns for Rewrite Rules

Research output: Chapter in Book/Conference proceedings/Edited volume › Conference contribution › Scientific › peer-review

69 Downloads (Pure)

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 languageEnglish
Title of host publicationHaskell 2024
Subtitle of host publicationProceedings of the 17th ACM SIGPLAN International Haskell Symposium
EditorsNiki Vazou, J. Garrett Morris
Place of PublicationNew York, NY
PublisherAssociation for Computing Machinery (ACM)
Pages14-26
Number of pages13
ISBN (Electronic)9798400711022
DOIs
Publication statusPublished - 2024
Event17th ACM SIGPLAN International Symposium on Haskell - Milan, Italy
Duration: 6 Sept 2024 → 7 Sept 2024
https://icfp24.sigplan.org/home/haskellsymp-2024

Conference

Conference17th ACM SIGPLAN International Symposium on Haskell
Country/TerritoryItaly
CityMilan
Period6/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