Tracing and Debugging Functional Programs
Tracing shows the programmer what happens during a computation. It enables the programmer to see how different parts of the program cause the observed input/output actions. Tracing is used primarily for debugging, that is, for localising the faulty program part that causes an undesirable observable behaviour.
For declarative languages new tracing methods that are different from, and arguably more powerful than, conventional methods for imperative languages have been developed. These methods take advantage of the purity of declarative languages, that is, explicit data flow and absence of side effects. Functional languages are particularly suitable for these methods, because they have simple and well-studied semantics, and lazy functional languages are the most widely used completely pure programming languages.
In 2000 Colin Runciman, Malcolm Wallace and I started developing the Haskell tracing tool Hat. Hat traces Haskell 98 programs that use the Haskell 98 standard libraries. For example, Hat has been used to trace the Haskell compiler nhc98 (itself written in Haskell) while it compiled a Haskell module. Trace files of up to 2GB can be produced and effectively viewed. Hat was no longer maintained since about 2007, but in autumn 2012 I started reviving Hat and I am extending it again.
- Comprehending Finite Maps for Algorithmic
Debugging of Higher-Order Functional Programs. Olaf Chitil and Thomas Davie. 10th International ACM SIGPLAN Conference on Principles and Practice of Declarative Programming (PPDP 2008).
Combining Algorithmic Debugging and Program Slicing. Josep Silva and Olaf Chitil.
Eighth ACM-SIGPLAN International Symposium on Principles and Practice of Declarative Programming (PPDP 2006). Pages 157-166. ACM Press. July 2006.
- Structure and properties of traces for functional programs. Olaf Chitil and Yong Luo. In Ian Mackie, editor, Proceedings of the 3rd International Workshop on Term Graph Rewriting, Termgraph 2006, ENTCS, pages 39-63. Elsevier, April 2007.
- is a library plus viewing tool for lightweight debugging of functional logic programs in Curry by observations. The programmer annotates expressions of interest in their program. With the viewing tool the programmer then views the values the annotated expressions have in a computation.