| a feeling of frustration around here. So here is my question:
|
| How do people out there debug Haskell programs???
|
| Please note that I am not talking about toy programs of a few dozen
| lines. How do e.g. the people at Glasgow find the bugs in GHC (which is
| a fairly large Haskell program)?
You're right that there is a problem. I think that it has been addressed
only slowly because
a) it's a genuinely difficult problem -- it isn't clear what a debugger
for a lazy language should do.
b) it's a less pressing problem than in many languages -- a common experience
is that once the program gets past the type checker it works.
So far as (a) is concerned, there is old work by O'Donnel and Hall,
more recent work by Henrik Nilsson and Peter Fritzson
(abstract on http://www.dcs.glasgow.ac.uk/jfp/bibliography/bibliography.html)
and more recent still by Jan Sparud at York.
(b) is clearly a cop-out -- but it helps explain why (in combination with
(a)) building a debugger hasn't made it to the top of our priority list.
What do people actually do? An interactive system like Hugs helps a lot.
You can interactively evaluate expressions involving functions "inside" your
program. Of course it's not the whole answer -- manufacturing the inputs
that break your function is sometimes the main problem -- but it helps.
In debugging GHC we don't use an interactive system. Rather, the compiler
is structured as a linear sequence of passes, and we arrange to be able to
print the result of each pass. It's usually pretty easy to figure out
what's wrong from that information.
There are two sorts of error which are particularly painful:
1. non-termination. The trouble here is that you get no information
whatsoever! Stack backtraces are usually unhelpful.
2. Error "head []". If you take head of nil, or some other similar
missing-pattern error, then it's often really hard to know who
the "caller" was. The trouble is that you want to know who
*built* the thunk (head []) rather than who *demanded* it.
My guess is that better info about these two sorts of errors would
get 50% of the way for 10% of the effort.
Simon