Tracing the evaluation of lazy functional languages: A model and its implementation

  • Richard Watson
  • Eric Salzman
Session 8
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1345)


We address the problem of producing a trace of the evaluation of a program written in a lazy functional language. To avoid ambiguities and possible misunderstandings it is essential that the trace structure is defined with respect to a formally described model of program evaluation.

We provide such a formal semantics for lazy evaluation of a simple lazy language, based closely on the work of Launchbury. The trace corresponds to the sequence of expression reductions defined by the evaluation model.

We also present a scheme to generate a concrete trace of the evaluation of programs written in the target language, based on its semantic rules. We employ a two-step transformational approach: first transform the program so that, on execution, it generates a call-by-name trace as result, then further transform this trace to a call-by-need trace.


functional programming debugging lazy evaluation program transformation 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. Z. Ariola, M. Felleisen, J. Mariast, M. Odersky, and P. Wadler. A call-by-need lambda calculus. In Proceedings of the 22nd ACM Symposium on Principles of Programming Languages, pages 233–246, 1995.Google Scholar
  2. M. Augustson and J. Reinfelds. A visual Miranda machine. In Proceedings, Software Education Conference SRIG-ET'94, Ed. M. Purvis, IEEE Computer Society Press, Los Alamitos California, pages 198–203, 1995.Google Scholar
  3. R. Bird and P. Wadler. Introduction to Functional Programming. Prentice Hall, 1988.Google Scholar
  4. J. Gibbons and K. Wansbrough. Tracing lazy functional languages. In Proceedings of Computing: The Australasian Theory Symposium”, 1996.Google Scholar
  5. D. Goldson. A symbolic calculator for non-strict functional languages. The Computer Journal, 37(3):177–187, 1994.CrossRefGoogle Scholar
  6. C. Hall, K. Hammond, and J. O'Donnell. An algorithmic and semantic approach to debugging. In Proceedings of the 1990 Glasgow Workshop on Functional Programming, pages 44–53, 1990.Google Scholar
  7. A. Kishon. Theory and Art of Semantics-Directed Program Execution Monitoring. PhD thesis, Department of Computer Science, Yale University, 1992.Google Scholar
  8. J. Launchbury. A natural semantics for lazy evaluation. In Proceedings of the 20th ACM Symposium on Principles of Programming Languages, pages 144–154, 1993.Google Scholar
  9. L. Naish and T. Barbour. Towards a portable lazy functional declarative debugger. In Proceedings of the 19th Australian Computer Science Conference, 1996. Also available as Technical Report 95/27, Department of Computer Science, University of Melbourne.Google Scholar
  10. H. Nilsson and P. Fritzson. Algorithmic debugging for lazy functional languages. Journal of Functional Programming, 4(3):337–369, 1994.Google Scholar
  11. J. T. O'Donnell and C. V. Hall. Debugging in applicative languages. Lisp and Symbolic Computation, 1(2):113–145, 1988.CrossRefGoogle Scholar
  12. S. L. Peyton Jones. The Implementation of Functional Programming Languages. Prentice-Hall, 1987.Google Scholar
  13. C. Runciman and D. Wakeling. Heap profiling for lazy functional programs. Journal of Functional Programming, 3(2):217–245, 1993.Google Scholar
  14. P. M. Sansom and S. L. Peyton Jones. Time and space profiling for non-strict higher-order functional languages. In Proceedings of the 22nd ACM Symposium on Principles of Programming Languages, pages 355–366, 1995.Google Scholar
  15. P. Sestoft. Deriving a lazy abstract machine. Journal of Functional Programming, 7 (3), 1997. To appear.Google Scholar
  16. E. Shapiro. Algorithmic Program Debugging. MIT Press, 1982.Google Scholar
  17. R. M. Snyder. Lazy debugging of lazy functional programs. New Generation Computing, 8:139–161, 1990.Google Scholar
  18. J. Sparud. A Transformational Approach to Debugging Lazy Functional Programs. Licentate thesis, Department of Computer Science, Chalmers University of Technology, 1996.Google Scholar
  19. J. Sparud and C. Runciman. Tracing Lazy Functional Computations Using Redex Trails. In Proceedings of the Ninth International Symposium on Programming Languages, Implementations, Logics, and Programs (PLILP97), 1997.Google Scholar
  20. R. Watson. Tracing Lazy Evaluation by Program Transformation. PhD thesis, School of Multimedia and Information Technology, Southern Cross University, 1997.Google Scholar
  21. R. Watson and E. Salzman. A trace browser for a lazy functional language. In Proceedings of the Twentieth Australian Computer Science Conference, pages 356–363, 1997.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1997

Authors and Affiliations

  • Richard Watson
    • 1
  • Eric Salzman
    • 2
  1. 1.Department of Mathematics and ComputingUniversity of Southern QueenslandToowoombaAustralia
  2. 2.Department of Computer ScienceThe University of QueenslandAustralia

Personalised recommendations