how to debug?

David Roundy droundy@jdj5.mit.edu
Sat, 5 Oct 2002 18:41:06 -0400


How does one debug in haskell? I have a function that I could swear should
behave differently than it does, and after tracking down bugs for many
hours, I'm wondering if there's any way to step through the evaluation of a
haskell function?

The other way I would be debugging in an imperative language would be to
sprinkle printfs around.  Is there any way to do something like that
cleanly in haskell?  The only thing I can think of would be to modify every
function to accept an additional parameter, which seems like it's more
likely to introduce bugs than remove them...

For what it's worth I'm using ghc, and the only debugging options it seems
to have are for debugging the compiler itself.  I would be happy to install
and use hugs for debugging if it has some nicer debugging mode.

I have already isolated my bug within one function, but that function has
somewhat funky recursion, and uses an array (which I'm none too familiar
with in haskell), and there aren't any smaller parts that I can see to
test.  :(
-- 
David Roundy
http://civet.berkeley.edu/droundy/