[Haskell-cafe] how do you debug programs?
mnislaih at gmail.com
Wed Sep 6 05:34:05 EDT 2006
There are several ways to debug a Haskell program.
The most advanced ones are based in offline analysis of traces, I
think Hat  is the most up-to-date tool for this. There is a Windows
port of Hat at .
Another approach is to simply use Debug.Trace. A more powerful
alternative for this approach is Hood . Even if it hasn't been
updated in some time, Hood works perfectly with the current ghc
distribution. Even more, Hugs has it already integrated . You can
simply import Observe and use observations directly in your program.
f' = observe "f" f
f a b = ....
And then in hugs the expression:
> f' 1 2
would output what you want.
Finally, the GHCi debugger project  aims to bring dynamic
breakpoints and intermediate values observation to GHCi in a near
future. Right now the tool is only available from the site as a
modified version of GHC, so unfortunately you will have to compile it
yourself if you want to try it.
On 06/09/06, Tamas K Papp <tpapp at princeton.edu> wrote:
> I would like to learn a reasonable way (ie how others do it) to debug
> programs in Haskell. Is it possible to "see" what's going on when a
> function is evaluated? Eg in
> f a b = let c = a+b
> d = a*b
> in c+d
> f 1 2
> would output something like
> f called with values 1 2
> c is now (+) a b => (+) 1 2 => 3
> d is now (*) a b => (*) 1 2 => 2
> Or maybe I am thinking the wrong way, and functional programming has
> its own debugging style...
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe