ABSTRACT
This paper presents an automatic deforestation system, stream fusion, based on equational transformations, that fuses a wider range of functions than existing short-cut fusion systems. In particular, stream fusion is able to fuse zips, left folds and functions over nested lists, including list comprehensions. A distinguishing feature of the framework is its simplicity: by transforming list functions to expose their structure, intermediate values are eliminated by general purpose compiler optimisations.
We have reimplemented the Haskell standard List library on top of our framework, providing stream fusion for Haskell lists. By allowing a wider range of functions to fuse, we see an increase in the number of occurrences of fusion in typical Haskell programs. We present benchmarks documenting time and space improvements.
- Olaf Chitil. Type inference builds a short cut to deforestation. In ICFP '99: Proceedings of the fourth ACM SIGPLAN International Conference on Functional programming, pages 249--260, New York, NY, USA, 1999. ACM Press. Google Scholar
Digital Library
- Olaf Chitil. Promoting non-strict programming. In Draft Proceedings of the 18th International Symposium on Implementation and Application of Functional Languages, IFL 2006, pages 512--516, Budapest, Hungary, September 2006. Eotvos Lorand University.Google Scholar
- Duncan Coutts, Don Stewart, and Roman Leshchinskiy. Rewriting Haskell strings. In Practical Aspects of Declarative Languages 8th International Symposium, PADL 2007, pages 50--64. Springer-Verlag, January 2007. Google Scholar
Digital Library
- Nils Anders Danielsson and Patrik Jansson. Chasing bottoms, a case study in program verification in the presence of partial and infinite values. In Dexter Kozen, editor, Proceedings of the 7th International Conference on Mathematics of Program Construction, MPC 2004, volume 3125 of LNCS, pages 85--109. Springer-Verlag, July 2004.Google Scholar
- Jeremy Gibbons. Streaming representation-changers. In D. Kozen, editor, Mathematics of Program Construction, pages 142--168. Springer-Verlag, 2004. LNCS 523.Google Scholar
Cross Ref
- Jeremy Gibbons and Geraint Jones. The under-appreciated unfold. In ICFP '98: Proceedings of the third ACM SIGPLAN International Conference on Functional programming, pages 273--279, New York, NY, USA, 1998. ACM Press. Google Scholar
Digital Library
- Andrew Gill. Cheap Deforestation for Non-strict Functional Languages. PhD thesis, University of Glasgow, January 1996.Google Scholar
- Andrew Gill, John Launchbury, and Simon Peyton Jones. A shortcut to deforestation. In Conference on Functional Programming Languages and Computer Architecture, pages 223--232, June 1993. Google Scholar
Digital Library
- Zhenjiang Hu, Hideya Iwasaki, and Masato Takeichi. Deriving structural hylomorphisms from recursive definitions. In Proceedings 1st ACM SIGPLAN International Conference on Functional Programming, volume 31(6), pages 73--82. ACM Press, New York, 1996. Google Scholar
Digital Library
- Patricia Johann. Short cut fusion: Proved and improved. In SAIG 2001: Proceedings of the Second International Workshop on Semantics, Applications, and Implementation of Program Generation, pages 47--71, London, UK, 2001. Springer-Verlag. Google Scholar
Digital Library
- Thomas Johnsson. Lambda lifting: transforming programs to recursive equations. In Functional programming languages and computer architecture. Proc. of a conference (Nancy, France, Sept.1985), New York, NY, USA, 1985. Springer-Verlag Inc. Google Scholar
Digital Library
- John Launchbury and Ross Paterson. Parametricity and unboxing with unpointed types. In European Symposium on Programming, pages 204--218, 1996. Google Scholar
Digital Library
- John Launchbury and Tim Sheard. Warm fusion: deriving build-catas from recursive definitions. In FPCA '95: Proceedings of the seventh international conference on Functional programming languages and computer architecture, pages 314--323, New York, NY, USA, 1995. ACM Press. Google Scholar
Digital Library
- Erik Meijer, Maarten Fokkinga, and Ross Paterson. Functional programming with bananas, lenses, envelopes and barbed wire. In J. Hughes, editor, Proceedings 5th ACM Conf. on Functional Programming Languages and Computer Architecture, FPCA'91, Cambridge, MA, USA, 26-30 Aug 1991, volume 523, pages 124--144. Springer-Verlag, Berlin, 1991. Google Scholar
Digital Library
- Will Partain. The nofib benchmark suite of Haskell programs. In Functional Programming, pages 195--202, 1992. Google Scholar
Digital Library
- Simon Peyton Jones. Constructor Specialisation for Haskell Programs, 2007. Submitted for publication.Google Scholar
- Simon Peyton Jones and André L. M. Santos. A transformation-based optimiser for Haskell. Sci. Comput. Program., 32(1-3): 3--47, 1998. ISSN 0167-6423. Google Scholar
Digital Library
- Simon Peyton Jones, Andrew Tolmach, and Tony Hoare. Playing by the rules: rewriting as a practical optimisation technique in GHC. In Ralf Hinze, editor, 2001 Haskell Workshop. ACM SIGPLAN, September 2001.Google Scholar
- Simon Peyton Jones et al. The Haskell 98 language and libraries: The revised report. Journal of Functional Programming, 13(1): 0--255, Jan 2003.Google Scholar
- Colin Runciman. SmallCheck 0.2: another lightweight testing library in Haskell. http://article.gmane.org/gmane.comp.lang.haskell.general/14461, 2006.Google Scholar
- Josef Svenningsson. Shortcut fusion for accumulating parameters & zip-like functions. In ICFP '02: Proceedings of the seventh ACM SIGPLAN International Conference on Functional programming, pages 124--132, New York, NY, USA, 2002. ACM Press. Google Scholar
Digital Library
- Akihiko Takano and Erik Meijer. Shortcut deforestation in calculational form. In Conf. Record 7th ACM SIGPLAN/SIGARCH Int. Conf. on Functional Programming Languages and Computer Architecture, FPCA'95, pages 306--313. ACM Press, New York, 1995. Google Scholar
Digital Library
- The GHC Team. The Glasgow Haskell Compiler (GHC). http://haskell.org/ghc, 2007.Google Scholar
- Philip Wadler. List comprehensions. In Simon Peyton Jones, editor, The implementation of functional programming languages. Prentice Hall, 1987. Chapter 15.Google Scholar
- Philip Wadler. Deforestation: transforming programs to eliminate trees. Theoretical Computer Science, (Special issue of selected papers from 2nd European Symposium on Programming), 73(2):231--248, 1990. Google Scholar
Digital Library
Index Terms
Stream fusion: from lists to streams to nothing at all
Recommendations
Stream fusion: from lists to streams to nothing at all
Proceedings of the ICFP '07 conferenceThis paper presents an automatic deforestation system, stream fusion, based on equational transformations, that fuses a wider range of functions than existing short-cut fusion systems. In particular, stream fusion is able to fuse zips, left folds and ...
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 ...
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 ...







Comments