skip to main content
10.1145/2543728.2543736acmconferencesArticle/Chapter ViewAbstractPublication PagespepmConference Proceedingsconference-collections
research-article

The HERMIT in the stream: fusing stream fusion's concatMap

Published:11 January 2014Publication History

ABSTRACT

Stream 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 Glasgow Haskell Compiler's user-directed rewriting system. A transformation which allows the compiler to fuse many uses of concatMap has previously been proposed, but never implemented, because the host rewrite system was not expressive enough to implement the proposed transformation. In this paper, we develop a custom optimization plugin which implements the proposed concatMap transformation, and study the effectiveness of the transformation in practice. We also provide a new translation scheme for list comprehensions which enables them to be optimized. Within this framework, we extend the transformation to monadic streams. Code featuring uses of concatMap experiences significant speedup when compiled with this optimization. This allows Stream Fusion to outperform its rival, foldr/build, on many list computations, and enables performance-sensitive code to be expressed at a higher level of abstraction.

References

  1. D. Burkett, J. Blitzer, and D. Klein. Joint Parsing and Alignment with Weakly Synchronized Grammars. In Human Language Technologies: The 2010 Annual Conference of the North American Chapter of the Association for Computational Linguistics, pages 127--135. Association for Computational Linguistics, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. D. Coutts. phStream Fusion: Practical Shortcut Fusion for Coinductive Sequence Types. PhD thesis, University of Oxford, 2010.Google ScholarGoogle Scholar
  3. D. Coutts, R. Leshchinskiy, and D. Stewart. Stream fusion: From lists to streams to nothing at all. In Proceedings of the 12th ACM SIGPLAN International Conference on Functional Programming, pages 315--326, Freiburg, Germany, 2007. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. A. Farmer, A. Gill, E. Komp, and N. Sculthorpe. The HERMIT in the machine: A plugin for the interactive transformation of GHC core language programs. In Proceedings of the ACM SIGPLAN Haskell Symposium, Haskell '12, pages 1--12. ACM, 2012. 10.1145/2364506.2364508. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. A. Gill. Cheap deforestation for non-strict functional languages. PhD thesis, The University of Glasgow, January 1996.Google ScholarGoogle Scholar
  6. A. Gill. A Haskell hosted DSL for writing transformation systems. In Proceedings of the IFIP TC 2 Working Conference on Domain-Specific Languages, DSL '09, pages 285--309. Springer-Verlag, July 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. A. Gill, J. Launchbury, and S. L. Peyton Jones. A short cut to deforestation. pages 223--232. ACM Press, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. J.-Y. Girard. Interprétation fonctionelle et élimination des coupures de l'arithmétique d'ordre supérieur. PhD thesis, Université Paris VII, 1972.Google ScholarGoogle Scholar
  9. T. Grosser, H. Zheng, R. Aloor, A. Simbürger, A. Größlinger, and L.-N. Pouchet. Polly - Polyhedral optimization in LLVM. In First International Workshop on Polyhedral Compilation Techniques, 2011.Google ScholarGoogle Scholar
  10. D. Grune and C. J. Jacobs. Parsing Techniques: A Practical Guide. Springer-Verlag New York Inc, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. R. Hinze, T. Harper, and D. W. James. Theory and Practice of Fusion. Implementation and Application of Functional Languages, pages 19--37, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. C. Höner zu Siederdissen. Sneaking around concatMap: Efficient combinators for dynamic programming. In Proceedings of the 17th ACM SIGPLAN International Conference on Functional Programming, pages 215--226, Copenhagen, Denmark, 2012. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. C. Höner zu Siederdissen, I. L. Hofacker, and P. F. Stadler. How to Multiply Dynamic Programming Algorithms. In Brazilian Symposium on Bioinformatics (BSB 2013), Lecture Notes in Bioinformatics, volume 8213. Springer, Heidelberg, 2013.Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. F. W. Huang, J. Qin, C. M. Reidys, and P. F. Stadler. Partition function and base pairing probabilities for RNA--RNA interaction prediction. Bioinformatics, 25 (20): 2646--2654, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. C. Lattner and V. Adve. LLVM: A Compilation Framework for Lifelong Program Analysis & Transformation. In Code Generation and Optimization, 2004. CGO 2004. International Symposium on, pages 75--86. IEEE, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. B. Lippmeier, M. M. Chakravarty, G. Keller, and A. Robinson. Data Flow Fusion with Series Expressions in Haskell. In Proceedings of the 2013 ACM SIGPLAN Haskell Symposium, Haskell '13, pages 93--104. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. G. Mainland, R. Leshchinskiy, and S. Peyton Jones. Exploiting Vector Instructions with Generalized Stream Fusion. In Proceedings of the 18th ACM SIGPLAN International Conference on Functional Programming, pages 37--48, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. B. O'Sullivan. http://hackage.haskell.org/package/criterion.Google ScholarGoogle Scholar
  19. W. Partain. The nofib Benchmark Suite of Haskell Programs. In Proceedings of the 1992 Glasgow Workshop on Functional Programming, pages 195--202, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. S. Peyton Jones, editor. phHaskell 98 Language and Libraries -- The Revised Report. Cambridge University Press, Cambridge, England, 2003.Google ScholarGoogle Scholar
  21. S. Peyton Jones. Call-pattern Specialisation for Haskell Programs. In Proceedings of the 12th ACM SIGPLAN International Conference on Functional Programming, ICFP '07, pages 327--337. ACM, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. J. C. Reynolds. Towards a theory of type structure. In Colloque sur la Programmation, volume 19 of Lecture Notes in Computer Science, pages 408--423. Springer-Verlag, 1974. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. A. Santos. Compilation by Transformation in Non-Strict Functional Languages. PhD thesis, University of Glasgow, 1995.Google ScholarGoogle Scholar
  24. N. Sculthorpe, A. Farmer, and A. Gill. The HERMIT in the tree: Mechanizing program transformations in the GHC core language. In Implementation and Application of Functional Languages 2012, volume 8241 of Lecture Notes in Computer Science. Springer, 2013.Google ScholarGoogle Scholar
  25. N. Sculthorpe, N. Frisby, and A. Gill. The Kansas University Rewrite Engine: A Haskell-embedded strategic programming language with custom closed universes. Submitted to the Journal of Functional Programming, 2013.Google ScholarGoogle Scholar
  26. M. Sulzmann, M. M. T. Chakravarty, S. Peyton Jones, and K. Donnelly. System F with type equality coercions. In Types in Language Design and Implementaion, pages 53--66. ACM, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. J. Svenningsson. Shortcut Fusion for Accumulating Parameters Zip-like Functions. PhD thesis, 2002.Google ScholarGoogle Scholar
  28. D. A. Terei and M. M. Chakravarty. An LLVM Backend for GHC. In Proceedings of the third ACM Haskell Symposium, pages 109--120. ACM, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. P. Wadler. List comprehensions. In S. Peyton Jones, editor, The Implementation of Functional Programming Languages, chapter 7. Prentice Hall International, 1987.Google ScholarGoogle Scholar
  30. P. Wadler. Deforestation: Transforming programs to eliminate trees. In Proceedings of the 2nd European Symposium on Programming, pages 344--358, London, UK, UK, 1988. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. R. C. Waters. Automatic transformation of series expressions into loops. ACM Trans. Program. Lang. Syst., 13 (1): 52--98, Jan. 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. B. A. Yorgey, S. Weirich, J. Cretin, S. Peyton Jones, D. Vytiniotis, and J. P. Magalhaes. Giving Haskell a promotion. In Types in Language Design and Implementation, pages 53--66. ACM, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. The HERMIT in the stream: fusing stream fusion's concatMap

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • Published in

      cover image ACM Conferences
      PEPM '14: Proceedings of the ACM SIGPLAN 2014 Workshop on Partial Evaluation and Program Manipulation
      January 2014
      202 pages
      ISBN:9781450326193
      DOI:10.1145/2543728

      Copyright © 2014 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 11 January 2014

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article

      Acceptance Rates

      PEPM '14 Paper Acceptance Rate17of22submissions,77%Overall Acceptance Rate66of120submissions,55%

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader