
Hello,
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. :(
aside from (useful) general advices already given, just few tips that I found useful when I needed to debug: -- to print debug dumps, you may use 'trace' function from IOExts (but beware, it may affect behavior of your program if used incorrectly) -- other way (safer, but slower to learn and use) is to use Hood library -- if your program fails with some really informative error message of type '*** Exception: Maybe.fromJust: Nothing', compiling it with profiling (-prof -auto-all) and running with +RTS -xc will give you a stack dump (pretty useful, well hidden feature :-) Zdenek Dvorak _________________________________________________________________ Chat with friends online, try MSN Messenger: http://messenger.msn.com

On Sun, Oct 06, 2002 at 07:57:18PM +0000, Zdenek Dvorak wrote:
Hello,
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?
-- other way (safer, but slower to learn and use) is to use Hood library
Which can be found at http://haskell.cs.yale.edu/hood/ I have not really used it but it looks cool ;) It is "tested with 4.08" and needed a few changes to work with 5.04 but nothing really difficult. Happy hacking Remi -- Diese Augen haben es gesehen Doch diese Augen schliessen sich Und ungehindert fliesst das Blut Und das Schweigen wird unerträglich laut
participants (2)
-
Remi Turk
-
Zdenek Dvorak