Abstract
The debugging of fully lazy functional programs can require searching a very large reduction-history space containing many delayed computations. A debugger should provide a means to obtain a source level representation of the computation, which can be large, and a means to select the appropriate part of the computation to investigate, which can be difficult. A method is presented to compile functional programs to combinator code such that a source-like representation of any part of a computation graph can be efficiently reconstructed at run-time. Other less efficient methods require excessive compile-time guidance as to the specific part of the computation to be investigated. Reconstruction, forward reduction, and a history-rollback mechanism combine to make the entire source-like reduction-history space dynamically available at run-time. The deferring of debugging decisions until run-time is called lazy dubugging. Once the computation-sequence is meaningfully and efficiently available, the problem of debugging becomes that of localizing the search for the error. Some searching issues are discussed with respect to graph browsing and user-interface design. The method shows promise as a programmer tool to debug programs and to informally reason about the time and space behavior of fully lazy functional programs, a nonintuitive process due to the subtleness of sharing and delayed computations.
Similar content being viewed by others
Explore related subjects
Discover the latest articles, news and stories from top researchers in related subjects.References
Bentley, J.,Writing Efficient Programs, Prentice-Hall, Englewood Cliffs, NJ, 1982.
Augustsson, L. and Johnsson, T., “The Chalmers lazy-ML compiler,”The Computer Journal, Vol. 32, No. 2, pp. 127–141, 1989.
Bentley, J.,Programming Pearls, AT&T Bell Laboratories, Murray Hill, NJ, 1986.
Burge, W. H.,Recursive Programming Techniques, Addison-Wesley, Reading, MA, 1974.
Burn, G. L., Peyton Jones, S. L., and Robson, J. D., “The spineless G-machine,”Proceedings of the 1988 ACM Symposium on Lisp and Functional Programming, Association for Computing Machinery, Snowbird, UT, pp. 244–258, 1988.
Eisenstadt, M. and Brayshaw, M., “The transparent PROLOG machine (TPM): An execution model and graphical debugger for logic programming,”Journal of Logic Programming, 5, pp. 277–342, 1988.
Glaser, H. W. and Thompson, P., “Lazy garbage collection,”Software—Practice and Experience, Vol. 17, No. 1, pp. 1–4, 1987.
Hennessy, J., “Symbolic debugging of optimized code,”ACM TOPLAS, Vol. 4, No. 3, pp. 323–344, July, 1982.
Hudak, P. and Goldberg, B., “Experiments in diffused combinator reduction,”Proceedings of the 1984 ACM Conference on LISP and Functional Programming, Association for Computing Machinery, pp. 167–176, August, 1984.
Hudak, P. and Kranz, D., “A combinator-based compiler for a functional language,”Proceedings of the 11th Annual ACM Symposium on the Principles of Programming Languages, Association for Computing Machinery, New York, pp. 122–132, January, 1984.
Hughes, J., “The design and implementation of programming languages,”,Ph.D. Thesis, Oxford University, July, 1984.
Johnsson, T., “Lambda lifting: Transforming programs to recursive equations,” inFunctional Languages and Computer Architecture, Lecture Notes in Computer Science 201 (Jean-Pierre Jouannaud ed.), Springer-Verlag, Berlin, pp. 190–203, September, 1985.
Lieberman, H., “Steps toward better debugging tools for LISP,”ACM Symposium on LISP and Functional Programming, Association for Computing Machinery, pp. 247–255, August, 1984.
O’Donnell, John T. and Hall, C. V., “Debugging in applicative languages,”Lisp and Symbolic Computation, 1, pp. 113–145, 1988.
Peyton Jones, S. L., “Parsing distfix operators”,Communications of the ACM, Vol. 29, No. 2, pp. 118–122, February, 1986.
Peyton Jones, S. L.,The Implementation of Functional Programming Languages, Prentice-Hall, New York, 1987.
Milner, R., “A theory of type polymorphism in programming,”Journal of Computer and System Sciences, 17, pp. 348–375, 1978.
Satterthwaite, E., “Debugging tools for high level languages,”Software—Practice and Experience, 2, pp. 197–217, 1972.
Shapiro, E. Y.,Algorithmic Program Debugging, MIT Press, Cambridge, MA, 1983.
Stoye, W. R., Clarke, T. J. W., and Norman, A. C., “Some practical methods for rapid combinator reduction”,Conference Record of the 1984 ACM Symposium on LISP and Functional Programming, Association for Computing Machinery, August, 1984.
Shu, N. C.,Visual Programming, Van Nostrand Reinhold, New York, 1988.
Tinker, P. and Katz, M., “Parallel execution of sequential scheme with Para Tran,”ACM, pp. 28–39, 1988.
Toyn, I. and Runciman, C., “Adapting combinator and SECD machines to display snapshots of functional computations,”New Generation Computing, 4, pp. 339–363, 1986.
Turner, D. A., “A new implementation technique for applicative languages,”Software— Practice and Experience, 9, pp. 31–49, 1979.
Turner, D. A., “Another algorithm for bracket abstraction,”The Journal of Symbolic Logic, Vol. 44, No. 2, pp. 267–270, June, 1979.
Wadsworth, C. P., “Semantics and pragmatics of the lambda calculus,”Ph.D. Thesis, Oxford University, 1971.
Wilensky, R.,LISPcraft, W. W. Norton, New York, 1984.
Kaisler, S.,INTERLISP: The Language and Its Usage, John Wiley & Sons, New York, 1986.
Author information
Authors and Affiliations
About this article
Cite this article
Snyder, R.M. Lazy debugging of lazy functional programs. New Gener Comput 8, 139–161 (1990). https://doi.org/10.1007/BF03037471
Received:
Revised:
Issue Date:
DOI: https://doi.org/10.1007/BF03037471