article

Recursion patterns and time-analysis

Abstract

This paper explores some ideas concerning the time-analysis of functional programs defined by instantiating typical recursion patterns such as folds, unfolds, and hylomorphisms. The concepts in this paper are illustrated through a rich set of examples in the Haskell programming language. We concentrate on unfolds and folds (also known as anamorphisms and catamorphisms respectively) of recursively defined types, as well as the more general hylomorphism pattern. For the latter, we use as case-studies two famous sorting algorithms, mergesort and quicksort. Even though time analysis is not compositional, we argue that splitting functions to expose the explicit construction of the recursion tree and its later consumption helps with this analysis.

References

  1. Lex Augusteijn. Sorting morphisms. In D. Swierstra, P. Henriques, and J. Oliveira, editors, 3rd International Summer School on Advanced Functional Programming, volume 1608 of LNCS, pages 1--27. Springer-Verlag, 1999.Google ScholarGoogle Scholar
  2. Thomas H. Cormen, Clifford Stein, Ronald L. Rivest, and Charles E. Leiserson. Introduction to Algorithms. McGraw-Hill Higher Education, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. J. Gibbons and G. Hutton. Proof methods for structured corecursive programs. In Proceedings of the 1st Scottish Functional Programming Workshop, 1999.Google ScholarGoogle Scholar
  4. Jeremy Gibbons and Geraint Jones. The under-appreciated unfold. In Proceedings of the 3rd ACM SIGPLAN International Conference on Functional Programming (ICFP'98), pages 273--279. ACM Press, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Zhenjiang Hu, Hideya Iwasaki, and Masato Takeichi. Deriving structural hylomorphisms from recursive definitions. In Proceedings of the ACM SIGPLAN International Conference on Functional Programming (ICFP'96), pages 73--82. ACM Press, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Grant Malcolm. Data structures and program transformation. Science of Computer Programming, 14(2--3):255--279, October 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Lambert Meertens. Paramorphisms. Technical Report RUU-CS-90-4, Utrecht University, Department of Computer Science, January 1990.Google ScholarGoogle Scholar
  8. Erik Meijer, Maarten Fokkinga, and Ross Paterson. Functional programming with bananas, lenses, envelopes and barbed wire. In J. Hughes, editor, Proceedings of the 5th ACM Conference on Functional Programming Languages and Computer Architecture (FPCA'91), volume 523 of LNCS. Springer-Verlag, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. David Sands. A naive time analysis and its theory of cost equivalence. Journal of Logic and Computation, 5(4):495--541, 1995.Google ScholarGoogle ScholarCross RefCross Ref

Index Terms

  1. Recursion patterns and time-analysis

        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

        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!