Abstract
Haskell is a very safe language, particularly because of its type system. However there will always be programs that do the wrong thing. Programmer fallibility, partial or incorrect specifications and typographic errors are but a few of the reasons that make bugs a fact of life. This paper is about the use and implementation of a debugger, called Buddha, which helps Haskell programmers understand why their programs misbehave. Traditional debugging tools that examine the program execution step-by-step are not suitable for Haskell because of its unorthodox evaluation strategy. Instead, a different approach is taken which abstracts away the evaluation order of the program and focuses on its high-level logical meaning.
This style of debugging is called Declarative Debugging, and it has its roots in the Logic Programming community. At the heart of the debugger is a tree which records information about the evaluation of the program in a manner which is easy to relate to the structure of the source code. It resembles a call graph annotated with the arguments and results of function applications, shown in their most evaluated form. Logical relationships between entities in the source are reflected in the links between nodes in the tree. An error diagnosis algorithm is applied to the tree in a top-down fashion in the search for causes of bugs.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
Nilsson, H., Spaurd, J.: The evaluation dependence tree as a basis for lazy functional debugging. Automated Software Engineering 4, 121–150 (1997)
Gansner, E., Koutsofios, E., North, S.: Drawing graphs with dot (2002), http://www.research.att.com/sw/tools/graphviz/dotguide.pdf
Jones, N., Mycroft, A.: Dataflow analysis of applicative programs using minimal function graphs. In: Proceedings of the 13th ACM SIGACT-SIGPLAN symposium on Principles of Programming Languages, Florida, pp. 296–306. ACM Press, New York (1986)
Claessen, K., Hughes, J.: Quickcheck: a lightweight tool for random testing of Haskell programs. In: International Conference on Functional Programming, pp. 268–279. ACM Press, New York (2000)
Naish, L., Barbour, T.: Towards a portable lazy functional declarative debugger. Australian Computer Science Communications 18, 401–408 (1996)
Sparud, J.: Tracing and Debugging Lazy Functional Computations. PhD thesis, Chalmers University of Technology, Sweden (1999)
Caballero, R., Rodri’guez-Artalejo, M.: A declarative debugging system for lazy functional logic programs. In: Hanus, M. (ed.) Electronic Notes in Theoretical Computer Science, vol. 64. Elsevier Science Publishers, Amsterdam (2002)
Pope, B., Naish, L.: A program transformation for debugging Haskell-98. Australian Computer Science Communications 25, 227–236 (2003) ISBN:0-909925-94-1
Claessen, K., Runciman, C., Chitil, O., Hughes, J., Wallace, M.: Testing and Tracing Lazy Functional Programs using QuickCheck and Hat. In: Jeuring, J., Jones, S.L.P. (eds.) AFP 2002. LNCS, vol. 2638, pp. 59–99. Springer, Heidelberg (2003)
Pope, B., Naish, L.: Practical aspects of declarative debugging in Haskell-98. In: Fifth ACM SIGPLAN Conference on Principles and Practice of Declarative Programming, pp. 230–240 (2003) ISBN:1-58113-705-2
Wadler, P.: Why no one uses functional languages. SIGPLAN Notices 33, 23–27 (1998)
Wallace, M., Chitil, O., Brehm, T., Runciman, C.: Multiple-view tracing for Haskell: a new hat. In: Preliminary Proceedings of the 2001 ACM SIGPLAN Haskell Workshop, pp. 151–170 (2001)
Gill, A.: Debugging Haskell by observing intermediate data structures. Technical report, University of Nottingham. In: Proceedings of the 4th Haskell Workshop (2000)
Nilsson, H.: Declarative Debugging for Lazy Functional Languages. PhD thesis, Department of Computer and Information Science Linköpings Universitet, S-581 83, Linköping, Sweden (1998)
Nilsson, H.: How to look busy while being as lazy as ever: The implementation of a lazy functional debugger. Journal of Functional Programming 11, 629–671 (2001)
Naish, L.: A declarative debugging scheme. Journal of Functional and Logic Programming 1997 (1997)
Naish, L., Barbour, T.: A declarative debugger for a logical-functional language. In: Forsyth, G., Ali, M. (eds.) Eighth International Conference on Industrial and Engineering Applications of Artificial Intelligence and Expert Systems — Invited and Additional Papers, Melbourne, DSTO General Document 51, vol. 2, pp. 91–99 (1995)
Naish, L.: Declarative debugging of lazy functional programs. Australian Computer Science Communications 15, 287–294 (1993)
Naish, L.: A three-valued declarative debugging scheme. Australian Computer Science Communications 22, 166–173 (2000)
Ennals, R., Peyton Jones, S.: Optimistic evaluation: an adaptive evaluation strategy for non-strict programs. In: Proceedings of the Eighth ACM SIGPLAN Conference on Functional Programming, pp. 287–298 (2003)
Ennals, R., Peyton Jones, S.: HsDebug: Debugging lazy programs by not being lazy. In: Jeuring, J. (ed.) ACM SIGPLAN 2003 Haskell Workshop, pp. 84–87. ACM Press, New York (2003)
Shapiro, E.: Algorithmic Program Debugging. MIT Press, Cambridge (1982)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2005 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Pope, B. (2005). Declarative Debugging with Buddha. In: Vene, V., Uustalu, T. (eds) Advanced Functional Programming. Lecture Notes in Computer Science, vol 3622. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11546382_7
Download citation
DOI: https://doi.org/10.1007/11546382_7
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-28540-3
Online ISBN: 978-3-540-31872-9
eBook Packages: Computer ScienceComputer Science (R0)