GHCi debugger status

Peter Hercek phercek at
Mon Nov 24 10:09:09 EST 2008

Pepe Iborra wrote:
> On Mon, Nov 24, 2008 at 2:03 PM, Peter Hercek <phercek at> wrote:
>> Maybe what Claus means is that he would like to see the dynamic
>>  stack and be able to traverse it and at each location in the
>>  dynamic stack he could investigate the free variables in the
>>  expression (corresponding to the dynamic stack slot). I actually
>>  considered this as a feature request but I decided that I would
>>  like to have this implemented sooner:
> As long as you start with :trace, you can see the dynamic stack with
> :history, and traverse it with :back.
> At any point in the stack the free variables are available, or so I believe.
> What is the missing feature you would like to request in this case?

Hmmm, I believe that dynamic stack is not the same as :trace history. 
The point is that the trace history shows all the evalueated expressions 
as they occure in time. But dynamic stack shows only the expressions 
which evaluation did not finish yet.


1 let fn a =
2   let f x = x + 1 in
3   case f a of
4     1 -> "one"
5     _ -> ""

When selected expression is "one" then the trace will contain
  something like this (just doing it from the top of my head):
  line 1-5 fn a = ...
  line 3-5 case f a of ...
  line 3 f a
  line 2 let f x = x + 1 in
  line 2 x + 1
  possibly something from outside which forces x and consequently a
  line 4 "one"

But the dynamic stack would contain:
  line 1-5 fn a = ...
  line 3-5 case f a of ...
  line 4 "one"

The difference is that the dynamic stack contains only the items which 
computation is not finished yet. The stuff which was already reduced to 
a final value is not there any more. This way you could trace the 
dynamic stack back to see what arguments was your function called with 
since the arguments must be free variables in the expression which 
called your function of interest.
Of course the same information is in the trace too ... that is if your 
trace history is long enough and you are willing to search it manually. 
That is the rason for ticket 2737. I do not want to search it manually!

Maybe trace is the dynamic stack and I did not realize what trace 
contains till now. That would be kind of a shame :-D


More information about the Glasgow-haskell-users mailing list