What is a good way to debug haskell code?

user53067 picture user53067 · Mar 23, 2009 · Viewed 8.3k times · Source

I have used the ghci debugger but would really prefer if it was somewhat integrated with a text editor to simplify the process of setting breakpoints. It should probably not strictly evaluate every visible variable but at least simplify the process of looking at the local state.

I recently found the trace function which has been helpful by allowing debug printouts from otherwise hard places.

Answer

Norman Ramsey picture Norman Ramsey · Mar 24, 2009

A good way to debug Haskell code is to write and test algebraic laws using QuickCheck and SmallCheck. There have been several Haskell debuggers including Hat, Hood, and Freya, but none of them have been perceived as sufficiently valuable to be worth maintaining for a long time.

When it's Haskell, you have to think differently about how to do things. The ICFP paper on the QuickCheck page has some good examples to get you started. If you want a real-world example xmonad is extensively debugged using QuickCheck.