Optimising Recursive Functions Yielding Multiple Results in Tuples in a Lazy Functional Language

  • John H. G. van Groningen
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1868)


We discuss a new optimisation for recursive functions yielding multiple results in tuples for lazy functional languages, like Clean and Haskell. This optimisation improves the execution time of such functions and also reduces the amount of memory allocated in the heap by these functions, which reduces garbage collection costs. In some cases execution time is improved by more than a factor of two and allocation costs by a factor of four. Furthermore, the space leak that is caused by selector nodes is removed.

This is achieved by reusing nodes allocated in the previous iteration of the recursion to create the nodes for the next iteration, by updating these nodes. Only the parts of the nodes that have changed are updated. Because of these updates, the code that is used to select an element of a tuple is not executed anymore for many selections, because the selector node was overwritten with a new selector node or the result before it is evaluated.


Black Hole Recursive Function Multiple Result Recursive Call Split Function 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    van Groningen, J.H.G., Nöcker, E.G.J.M.H., Smetsers, J.E.W.: Efficient Heap Management in the Concrete ABC Machine. Proceedings of the Third International Workshop on the Implementation of Functional Languages on Parallel Architectures. Technical Report Series CSTR 91-07. University of Southampton. U.K. (1991)Google Scholar
  2. 2.
    Hughes, J.: The design and implementation of programming languages. PhD thesis. Oxford University, Programming Research Group, technical monograph PRG-40 (July 1983)Google Scholar
  3. 3.
    Nöcker, E.G.J.M.H.: Efficient Parallel Functional Programming - Some Case Studies. In: Proceedings of the Fifth International Workshop on Implementation of Functional Languages, Nijmegen, The Netherlands, pp. 51-68 (September 1993) Technical Report 93-21Google Scholar
  4. 4.
    Jones, S.L.P.: The implementation of Functional Programming Languages. Prentice-Hall, Englewood Cliffs (1987)zbMATHGoogle Scholar
  5. 5.
    Sanders, P., Runciman, C.: LZW Text Compression in Haskell. In: Glasgow Workshop on Functional Programming, Ayr. Scotland, pp. 215–226 (1992)Google Scholar
  6. 6.
    Smetsers, J.E.W., Nöcker, E.G.J.M.H., van Groningen, J.H.G., Plasmeijer, M.J.: Generating Efficient Code for Lazy Functional Languages. In: Hughes, J. (ed.) FPCA 1991. LNCS, vol. 523, pp. 592–617. Springer, Heidelberg (1991)Google Scholar
  7. 7.
    Sparud, J.: Fixing Some Space Leaks without a Garbage Collector. In: FPCA 1993, Copenhagen, Denmark, pp. 117–122. ACM press, New York (1993)Google Scholar
  8. 8.
    Stoye, W.: The implementation of functional languages using custom hardware. PhD thesis. Cambridge University, Computing Laboratory, technical report 81 (December 1985)Google Scholar
  9. 9.
    Turner, D.: A proposal concerning the dragging problem, Burroughs ARC internal report (October 1985)Google Scholar
  10. 10.
    Wadler, P.: Fixing some space leaks with a garbage collector. Software Practice and Experience 18(9), 595–608 (1987)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2000

Authors and Affiliations

  • John H. G. van Groningen
    • 1
  1. 1.Department of Computer ScienceUniversity of NijmegenNijmegenThe Netherlands

Personalised recommendations