School of Computing

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.

Selected Papers

Other Software

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.



Last Updated: 22/03/2013