Re: [Haskell-cafe] how do you debug programs?

2006-09-07 Thread Tamas K Papp
On Wed, Sep 06, 2006 at 11:34:05AM +0200, Pepe Iborra wrote:
 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.

Dear Pepe,

Thank you for the information.  I finally ended up working with
Debug.Trace, and found the bug very quickly.  I also tried Hood, but
couldn't load it in ghci: import Observe can't find the library, but

% locate Observe
/usr/lib/ghc-6.4.2/hslibs-imports/util/Observe.hi
/usr/lib/ghc-6.4.2/hslibs-imports/util/Observe.p_hi
/usr/lib/hugs/libraries/Hugs/Observe.hs
/usr/lib/hugs/oldlib/Observe.hs

Does importing from hslibs-imports require something special?

Quite a bit of philosophical discussion erupted as a result of my
original question.  I understand the arguments of those who dislike
debuggers, but I don't think I could have done without some debugging.

It turns out that the problem was not in the algorithm, but in the
specification of the equation itself.  I was solving a continuous time
Hamilton-Jacobi-Bellman equation, and there was a point in the state
space where the supremum was infinity, giving stuff like 0/Inf and
their ilk.  I respecified the problem and now it works.

For those who think that it is always possible to break the problem up
into small pieces you can test individually (without a debugger): you
can't, at least not when solving functional equations.  The corner
cases (and nonconvergence, when using non-contraction methods, such as
PEA) are difficult to catch and reproduce.

Thanks for all the suggestions,

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


Re: [Haskell-cafe] how do you debug programs?

2006-09-07 Thread Pepe Iborra


On 07/09/2006, at 10:53, Tamas K Papp wrote:



Dear Pepe,

Thank you for the information.  I finally ended up working with
Debug.Trace, and found the bug very quickly.  I also tried Hood, but
couldn't load it in ghci: import Observe can't find the library, but

% locate Observe
/usr/lib/ghc-6.4.2/hslibs-imports/util/Observe.hi
/usr/lib/ghc-6.4.2/hslibs-imports/util/Observe.p_hi
/usr/lib/hugs/libraries/Hugs/Observe.hs
/usr/lib/hugs/oldlib/Observe.hs

Does importing from hslibs-imports require something special?


Hi Tamas

I'm glad to hear that you fixed it!

GHC includes Observe (the hs-libs-imports file you are seeing) only  
in the hidden 'util' package, which I believe is deprecated or not  
present in 6.6. If you want to use it, launch ghci with the flag '- 
package util'.
Or download Observe.hs from the Hood website and place it somewhere  
in the path.


Hmm, it would be handy to have a Cabal Hood package...

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


Re: [Haskell-cafe] how do you debug programs?

2006-09-06 Thread Pepe Iborra

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


Re: [Haskell-cafe] how do you debug programs?

2006-09-06 Thread Donald Bruce Stewart
mnislaih:
 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.

Pepe, would you like to put up a page on the haskell.org wiki about
debugging in Haskell? You could use the above mail as a start :)

-- Don



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


Re: [Haskell-cafe] how do you debug programs?

2006-09-06 Thread Pepe Iborra

Thanks for the suggestion Don,

I started the wiki page at http://haskell.org/haskellwiki/Debugging

On 06/09/06, Donald Bruce Stewart [EMAIL PROTECTED] wrote:

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

Pepe, would you like to put up a page on the haskell.org wiki about
debugging in Haskell? You could use the above mail as a start :)

-- Don





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