skip to main content
Purely functional data structures
Publisher:
  • Carnegie Mellon University
  • Schenley Park Pittsburgh, PA
  • United States
ISBN:978-0-591-64723-5
Order Number:AAI9813847
Pages:
150
Bibliometrics
Skip Abstract Section
Abstract

When a C programmer needs an efficient data structure for a particular problem, he or she can often simply look one up in any of a number of good textbooks or handbooks. Unfortunately, programmers in functional languages such as Standard ML or Haskell do not have this luxury. Although some data structures designed for imperative languages such as C can be quite easily adapted to a functional setting, most cannot, usually because they depend in crucial ways on assignments, which are disallowed, or at least discouraged, in functional languages. To address this imbalance, we describe several techniques for designing functional data structures, and numerous original data structures based on these techniques, including multiple variations of lists, queues, double-ended queues, and heaps, many supporting more exotic features such as random access or efficient catenation.

In addition, we expose the fundamental role of lazy evaluation in amortized functional data structures. Traditional methods of amortization break down when old versions of a data structure, not just the most recent, are available for further processing. This property is known as persistence, and is taken for granted in functional languages. On the surface, persistence and amortization appear to be incompatible, but we show how lazy evaluation can be used to resolve this conflict, yielding amortized data structures that are efficient even when used persistently. Turning this relationship between lazy evaluation and amortization around, the notion of amortization also provides the first practical techniques for analyzing the time requirements of non-trivial lazy programs.

Finally, our data structures offer numerous hints to programming language designers, illustrating the utility of combining strict and lazy evaluation in a single language, and providing non-trivial examples using polymorphic recursion and higher-order, recursive modules.

Cited By

  1. ACM
    Das A, Deyoung H, Mordido A and Pfenning F (2022). Nested Session Types, ACM Transactions on Programming Languages and Systems, 44:3, (1-45), Online publication date: 30-Sep-2022.
  2. ACM
    Martinez B, Viera M and Pardo A Just do it while compiling! Proceedings of the ACM SIGPLAN 2013 workshop on Partial evaluation and program manipulation, (77-86)
  3. Grzanek K and Cader A Protrace Proceedings of the 10th international conference on Artifical intelligence and soft computing: Part II, (468-475)
  4. ACM
    Defoe D, LeGrand R and Cytron R On the connection between functional programming languages and real-time Java scoped memory Proceedings of the 5th international workshop on Java technologies for real-time and embedded systems, (73-82)
  5. Abel A Towards generic programming with sized types Proceedings of the 8th international conference on Mathematics of Program Construction, (10-28)
  6. Fiat A and Kaplan H (2003). Making data structures confluently persistent, Journal of Algorithms, 48:1, (16-58), Online publication date: 1-Aug-2003.
  7. Fiat A and Kaplan H Making data structures confluently persistent Proceedings of the twelfth annual ACM-SIAM symposium on Discrete algorithms, (537-546)
  8. ACM
    Ganz S, Sabry A and Taha W (2001). Macros as multi-stage computations, ACM SIGPLAN Notices, 36:10, (74-85), Online publication date: 1-Oct-2001.
  9. ACM
    Ganz S, Sabry A and Taha W Macros as multi-stage computations Proceedings of the sixth ACM SIGPLAN international conference on Functional programming, (74-85)
  10. ACM
    Launchbury J, Lewis J and Cook B (1999). On embedding a microarchitectural design language within Haskell, ACM SIGPLAN Notices, 34:9, (60-69), Online publication date: 1-Sep-1999.
  11. ACM
    Launchbury J, Lewis J and Cook B On embedding a microarchitectural design language within Haskell Proceedings of the fourth ACM SIGPLAN international conference on Functional programming, (60-69)
  12. ACM
    Peyton Jones S, Shields M, Launchbury J and Tolmach A Bridging the gulf Proceedings of the 25th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, (49-61)
  13. Brodal G Finger search trees with constant insertion time Proceedings of the ninth annual ACM-SIAM symposium on Discrete algorithms, (540-549)
  14. ACM
    Okasaki C (1997). Catenable double-ended queues, ACM SIGPLAN Notices, 32:8, (66-74), Online publication date: 1-Aug-1997.
  15. ACM
    Okasaki C Catenable double-ended queues Proceedings of the second ACM SIGPLAN international conference on Functional programming, (66-74)
Contributors
  • The U.S. Military Academy at West Point
  • Microsoft Corporation

Recommendations