Hi Tamas

There are several ways to debug a Haskell program.

The most advanced ones are based in offline analysis of traces, I
think Hat [1] is the most up-to-date tool for this. There is a Windows
port of Hat at [5].

Another approach is to simply use Debug.Trace. A more powerful
alternative for this approach is Hood [2]. 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 [3]. You can
simply import Observe and use observations directly in your program.
For instance:

import Observe

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 [4] 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.

Cheers
pepe


1. www.haskell.org/hat
2. www.haskell.org/hood
3. http://cvs.haskell.org/Hugs/pages/users_guide/observe.html
4. http://haskell.org/haskellwiki/GHC/GHCiDebugger
5. http://www-users.cs.york.ac.uk/~ndm/projects/windows.php

On 06/09/06, Tamas K Papp <[EMAIL PROTECTED]> wrote:
Hi,

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

evaluating

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...

Thanks,

Tamas
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to