CPSC 429/529: Functional Programming

 

Instructor: Carsten Schürmann
Department of Computer Science
Yale University
Time: MWF 9:30-10:20
Room: AKW400

  Home
  Schedule
  Handouts
  Assignments
  Projects
  Links
 
 

Lecture 32: Debugging.

Henrik Nilsson will be our guest lecturer today. He will talk about a debugger for Haskell. In particular, we will see how a buggy version of the code from last time can be efficiently debugged.

Links:

Hood (Haskell Object Observation Debugger) is a library that permits to observe data structures at given program points. It can basically be used like print statements in imperative languages, but the lazy evaluation order is not affected and functions can be observed as well. Thus it can be use like "trace", but it is a much safer alternative. Works with (at least) Hugs and GHC.

Hat is an extension of nhc98 plus a browser. The specially compiled program creates a trace that shows the relationships between the redexes (i.e. function applications) evaluated by the computation. Debugging with the graphical browser works by going from (part of) a faulty output or error message backwards until the error is located. Much more sophisticated than Hood, and more like a traditional debugger in that the user does not need to change the code in order to debug, but it is an integral part of NHC, so Hugs/GHC users are out of luck for the time being. Still, as long as one sticks to Haskell98, one could use NHC/Hat for development/debugging, and then switch to GHC if speed is crucial.

Further Reading:

Henrik Nilsson. Tracing piece by piece: affordable debugging for lazy functional languages. Proceedings of the 1999 ACM SIGPLAN international conference on Functional programming, pages 36 - 47, Paris, France, September 1999.

Henrik Nilsson. Slides from this lecture.

Previous lecture: Lecture 31
Next lecture: Lecture 33