Reputation: 338
I'm new to Haskell and I'm getting an annoying behaviour when debugging.
When I rerun main, the breakpoint does not hit anymore but the breakpoint wasn't removed because :show breaks lists it. Anyone knows what's going on?
I'm on Ubuntu 11.10, 64 bits. I'll test it on a different environment tomorrow.
Thanks
Upvotes: 3
Views: 207
Reputation: 785
To avoid recomputations constant application forms are replaced with an indirection to its redex.
For example the following snippet the right hand side of 'papperlap' will be replaced with an indirection node pointing to '4'.
bla x = x + 1
papperlap = bla 3
If you set a breakpoint on 'bla' and ask for 'papperlap' twice you will see that 'bla' is applied only once. But if you ask for 'bla 3' twice, we will also stop twice:
*Main> :break bla
Breakpoint 0 activated at meerbla.hs:1:1-13
*Main> papperlap
Stopped at meerbla.hs:1:1-13
_result :: a = _
[meerbla.hs:1:1-13] *Main> :continue
4
*Main> papperlap
4
*Main> bla 3
Stopped at meerbla.hs:1:1-13
_result :: a = _
[meerbla.hs:1:1-13] *Main> :continue
4
*Main> bla 3
Stopped at meerbla.hs:1:1-13
_result :: a = _
[meerbla.hs:1:1-13] *Main> :continue
4
Upvotes: 0
Reputation: 2425
It's hard to know without seeing the code, but it sounds likely that on the second run of main the breakpoint is never reached because the result is cached because of lazy evaluation. It probably was a THUNK (a suspended evaluation) first time, and the second time it is already evaluated.
Upvotes: 2