skip to main content
article

Call-pattern specialisation for Haskell programs

Published:01 October 2007Publication History
Skip Abstract Section

Abstract

User-defined data types, pattern-matching, and recursion are ubiquitous features of Haskell programs. Sometimes a function is called with arguments that are statically known to be in constructor form, so that the work of pattern-matching is wasted. Even worse, the argument is sometimes freshly-allocated, only to be immediately decomposed by the function.

In this paper we describe a simple, modular transformation that specialises recursive functions according to their argument "shapes". We describe our implementation of this transformation in the Glasgow Haskell Compiler, and give measurements that demonstrate substantial performance improvements: a worthwhile 10% on average, with a factor of 10 in particular cases.

References

  1. Denis Bechet. Limix: a partial evaluator for partially static structures. Technical report, INRIA, 1994.Google ScholarGoogle Scholar
  2. Manuel Chakravarty, Roman Leshchinskiy, Simon Peyton Jones, and Gabriele Keller. Data Parallel Haskell: a status report. In ACM Sigplan Workshop on Declarative Aspects of Multicore Programming, Nice, January 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Duncan Coutts, Roman Leshchinskiy, and Don Stewart. Stream fusion: from lists to streams to nothing at all. In ACM SIGPLAN International Conference on Functional Programming (ICFP'07), Freiburg, Germany, October 2007a. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Duncan Coutts, Don Stewart, and Roman Leshchinskiy. Rewriting Haskell strings. In Practical Aspects of Declarative Languages (PADL'07), pages 50--64. Springer-Verlag, January 2007b. Google ScholarGoogle Scholar
  5. Neil D. Jones, Carsten K. Gomard, and Peter Sestoft. Partial Evaluation and Automatic Program Generation. Prentice Hall, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Torben Mogensen. Partially static structures in a self-applicable partial evaluator. In Partial Evaluation and Mixed Computation, 1988.Google ScholarGoogle Scholar
  7. Simon L. 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 ScholarGoogle Scholar
  8. S. L. Peyton Jones and J. Launchbury. Unboxed values as first class citizens. In R. J. M. Hughes, editor, ACM Conference on Functional Programming and Computer Architecture (FPCA'91), volume 523 of Lecture Notes in Computer Science, pages 636--666, Boston, 1991. Springer. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. S. L. Peyton Jones and A. Santos. A transformation-based optimiser for Haskell. Science of Computer Programming, 32 (1-3): 3--47, September 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. S. L. Peyton Jones, W. D. Partain, and A. Santos. Let-floating: moving bindings to give faster programs. In ACM SIGPLAN International Conference on Functional Programming (ICFP'96). ACM Press, Philadelphia, May 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Peter Thiemann. Higher-order redundancy elimination. In ACM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation (PEPM '94), pages 73--83, Orlando, Florida, June 1994. ACM.Google ScholarGoogle Scholar
  12. Peter Thiemann. Avoiding repeated tests in pattern matching. In Gilberto Filé, editor, 3rd International Workshop on Static Analysis, number 724 in Lecture Notes in Computer Science, pages 141--152, Padova, Italia, September 1993. Springer Verlag. ISBN 3-540-57264-3. Google ScholarGoogle Scholar

Index Terms

  1. Call-pattern specialisation for Haskell programs

      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

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 42, Issue 9
        Proceedings of the ICFP '07 conference
        September 2007
        331 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/1291220
        Issue’s Table of Contents
        • cover image ACM Conferences
          ICFP '07: Proceedings of the 12th ACM SIGPLAN international conference on Functional programming
          October 2007
          346 pages
          ISBN:9781595938152
          DOI:10.1145/1291151

        Copyright © 2007 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 1 October 2007

        Check for updates

        Qualifiers

        • article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!