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 _______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
