[Haskell] A few newbie questions about tracing/debugging and
order of execution
Robert Dockins
robdockins at fastmail.fm
Wed Dec 28 13:02:22 EST 2005
On Dec 28, 2005, at 12:07 PM, Hunter Kelly wrote:
> Yes, thank you, that did the trick! It produced the output for all
> steps,
> and in the order I would expect.
>
> Are there other techniques that people use to get debugging output?
>
Well, if you are writing code in the IO monad, obviously you can just
insert 'putStrLn', just like in your favorite imperative language.
For pure code, I generally try to write small functions and then
compose them to do larger tasks. That way I can exercise each
smaller function individually and see that I get the results I
expect. It is also more likely that your functions will just be
"obviously correct".
If that isn't possible for some reason I go to Debug.Trace and try to
find good places to sprinkle in the calls to 'trace'. I find that
attaching them to control structures usually works best.
If that doesn't cut it for you, there are also some interactive
Haskell debuggers. (http://www.haskell.org/libraries/#tracing).
Rob Dockins
Speak softly and drive a Sherman tank.
Laugh hard; it's a long way to the bank.
-- TMBG
More information about the Haskell
mailing list