Tracing the evaluation of lazy functional languages: A model and its implementation
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.
Keywordsfunctional programming debugging lazy evaluation program transformation
Unable to display preview. Download preview PDF.
- 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
- 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
- R. Bird and P. Wadler. Introduction to Functional Programming. Prentice Hall, 1988.Google Scholar
- J. Gibbons and K. Wansbrough. Tracing lazy functional languages. In Proceedings of Computing: The Australasian Theory Symposium”, 1996.Google Scholar
- 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
- A. Kishon. Theory and Art of Semantics-Directed Program Execution Monitoring. PhD thesis, Department of Computer Science, Yale University, 1992.Google Scholar
- 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
- 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
- H. Nilsson and P. Fritzson. Algorithmic debugging for lazy functional languages. Journal of Functional Programming, 4(3):337–369, 1994.Google Scholar
- S. L. Peyton Jones. The Implementation of Functional Programming Languages. Prentice-Hall, 1987.Google Scholar
- C. Runciman and D. Wakeling. Heap profiling for lazy functional programs. Journal of Functional Programming, 3(2):217–245, 1993.Google Scholar
- 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
- P. Sestoft. Deriving a lazy abstract machine. Journal of Functional Programming, 7 (3), 1997. To appear.Google Scholar
- E. Shapiro. Algorithmic Program Debugging. MIT Press, 1982.Google Scholar
- R. M. Snyder. Lazy debugging of lazy functional programs. New Generation Computing, 8:139–161, 1990.Google Scholar
- J. Sparud. A Transformational Approach to Debugging Lazy Functional Programs. Licentate thesis, Department of Computer Science, Chalmers University of Technology, 1996.Google Scholar
- 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
- R. Watson. Tracing Lazy Evaluation by Program Transformation. PhD thesis, School of Multimedia and Information Technology, Southern Cross University, 1997.Google Scholar
- 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