Abstract
There are now a variety of shortcut fusion techniques in the wild for removing intermediate data structures in Haskell. They are often presented, however, specialised to a specific data structure and interface. This can make it difficult to transfer these techniques to other settings. In this paper, we give a roadmap for a library writer who would like to implement fusion for his own library. We explain shortcut fusion without reference to any specific implementation by treating it as an instance of data refinement. We also provide an example application of our framework using the features available in the Glasgow Haskell Compiler.
Supplemental Material
- D. Coutts, R. Leshchinskiy, and D. Stewart. Stream fusion. Proceedings of the 12th ACM SIGPLAN international conference on Functional programming (ICFP '07), 42 (9): 315--326, Oct. 2007. ISSN 03621340. Google Scholar
Digital Library
- D. Coutts, D. Stewart, and R. Leshchinskiy. Rewriting Haskell Strings. In PADL '07, volume 4354, pages 50--64. Springer-Verlag, 2007. Google Scholar
Digital Library
- F. Dominguez. HFusion: a fusion tool based on Acid Rain plus extensions. Master thesis, Universidad de la República, 2009.Google Scholar
- P. J. Freyd. Remarks on algebraically compact categories. In M. P. Fourman, P. T. Johnstone, and A. M. Pitts, editors, Applications of Categories in Computer Science, volume 177 of LMS Lecture Note Series, pages 95--106. Cambridge University Press, 1992.Google Scholar
- N. Ghani, T. Uustalu, and V. Vene. Build, augment and destroy. Universally. pages 327--347. In Asian Symposium on Programming Languages, Proceedings, 2004.Google Scholar
Cross Ref
- J. Gibbons, G. Hutton, and T. Altenkirch. When is a function a fold or an unfold? In "Proceedings of the 4th International Workshop on Coalgebraic Methods in Computer Science". Elsevier Science, 2001.Google Scholar
- A. Gill and G. Hutton. The Worker Wrapper Transformation. Journal of Functional Programming, 19 (2): 227---251, 2009. Google Scholar
Digital Library
- A. Gill, J. Launchbury, and S. L. Peyton Jones. A short cut to deforestation. ACM Press, New York, New York, USA, 1993. Google Scholar
Digital Library
- T. Harper. Stream fusion on Haskell Unicode strings. In M. Morazán and S.-B. Scholz, editors, IFL'09 Proceedings of the 21st international conference on Implementation and application of functional languages, pages 125--140, Berlin, Sept. 2009. Springer-Verlag. Google Scholar
Digital Library
- M. Heine, B. Sørensen, and R. Glück. Introduction to Supercompilation. In J. Hatcliff, T. Mogensen, and P. Thiemann, editors, Partial Evaluation, volume 1706 of Lecture Notes in Computer Science, pages 246--270. Springer Berlin / Heidelberg, 1999. Google Scholar
Digital Library
- R. Hinze, D. W. James, and T. Harper. Theory and practice of fusion. In J. Hage, editor, Pre-proceedings of the 22nd Symposium on the Implementation and Application of Functional Languages (IFL '10), pages 402--421, September 2010. Google Scholar
Digital Library
- C. A. R. Hoare. Proof of correctness of data representations. Acta Informatica, 1: 271--281, 1972. ISSN 0001-5903.Google Scholar
Digital Library
- P. Johann and N. Ghani. phInitial algebra semantics is enough!, volume 4583 of Lecture Notes in Computer Science. Springer Berlin Heidelberg, Berlin, Heidelberg, 2007. Google Scholar
Digital Library
- S. P. Jones, A. Tolmach, and T. Hoare. Playing by the Rules: Rewriting as a practical optimisation technique in GHC. In Haskell Workshop, pages 203--233. ACM SIGPLAN, 2001.Google Scholar
- J. Launchbury and T. Sheard. Warm fusion: deriving build-catas from recursive definitions. Functional Programming Languages and Computer Architecture, page 314, 1995. Google Scholar
Digital Library
- S. L. Peyton-Jones and A. L. M. Santos. A transformation-based optimiser for Haskell. Science of Computer Programming, 32 (1-3): 3--47, Sept. 1998. ISSN 01676423. Google Scholar
Digital Library
- J. Svenningsson. Shortcut fusion for accumulating parameters & zip-like functions. In Proceedings of the seventh ACM SIGPLAN international conference on Functional programming - ICFP '02, volume 37, pages 124--132, New York, New York, USA, 2002. ACM Press. Google Scholar
Digital Library
- A. Takano and E. Meijer. Shortcut deforestation in calculational form. Functional Programming Languages and Computer Architecture, page 306, 1995. Google Scholar
Digital Library
- J. Voigtlander. Proving correctness via free theorems: the case of the destroy/build-rule. ACM/SIGPLAN Workshop Partial Evaluation and Semantics-Based Program Manipulation, 2008. Google Scholar
Digital Library
- P. Wadler. Theorems for free! In FPCA '89: Proceedings of the fourth international conference on Functional programming languages and computer architecture, pages 347---359, London, 1989. ACM. Google Scholar
Digital Library
Index Terms
A library writer's guide to shortcut fusion
Recommendations
A library writer's guide to shortcut fusion
Haskell '11: Proceedings of the 4th ACM symposium on HaskellThere are now a variety of shortcut fusion techniques in the wild for removing intermediate data structures in Haskell. They are often presented, however, specialised to a specific data structure and interface. This can make it difficult to transfer ...
Multiple intermediate structure deforestation by shortcut fusion
Shortcut fusion is a well-known optimization technique for functional programs. Its aim is to transform multi-pass algorithms into single pass ones, achieving deforestation of the intermediate structures that multi-pass algorithms need to construct. ...
The HERMIT in the stream: fusing stream fusion's concatMap
PEPM '14: Proceedings of the ACM SIGPLAN 2014 Workshop on Partial Evaluation and Program ManipulationStream Fusion, a popular deforestation technique in the Haskell community, cannot fuse the concatMap combinator. This is a serious limitation, as concatMap represents computations on nested streams. The original implementation of Stream Fusion used the ...







Comments