Practical aspects of declarative debugging in Haskell 98

Bernard Pope, Lee Naish
2003 Proceedings of the 5th ACM SIGPLAN international conference on Principles and practice of declaritive programming - PPDP '03  
This thesis is about the design and implementation of a debugging tool which helps Haskell programmers understand why their programs do not work as intended. The traditional debugging technique of examining the program execution step-by-step, popular with imperative languages, is less suitable for Haskell because its unorthodox evaluation strategy is difficult to relate to the structure of the original program source code. We build a debugger which focuses on the high-level logical meaning of a
more » ... program rather than its evaluation order. This style of debugging is called declarative debugging, and it originated in logic programming languages. 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 program. Links between nodes in the tree reflect logical relationships between entities in the source code. An error diagnosis algorithm is applied to the tree in a top-down fashion, searching for causes of bugs. The search is guided by an oracle, who knows how each part of the program should behave. The oracle is normally a humantypically the person who wrote the program -however, much of its behaviour can be encoded in software. An interesting aspect of this work is that the debugger is implemented by means of a program transformation. That is, the program which is to be debugged is transformed into a new one, which when evaluated, behaves like the original program but also produces the evaluation tree as a side-effect. The transformed program is augmented with code to perform the error diagnosis on the tree. Running the transformed program constitutes the evaluation of the original program plus a debugging iii session. The use of program transformation allows the debugger to take advantage of existing compiler technology -a whole new compiler and runtime environment does not need to be written -which saves much work and enhances portability. The technology described in this thesis is well-tested by an implementation in software. The result is a useful tool, called buddha, which is publicly available and supports all of the Haskell 98 standard. iv
doi:10.1145/888251.888273 dblp:conf/ppdp/PopeN03 fatcat:yoyz5zy4yjhlfhasmhm34x6ovi