could ghci debugger search for free variables better?

Simon Marlow marlowsd at
Fri Oct 24 08:49:26 EDT 2008

Peter Hercek wrote:
> May be my approach to debugging with ghci is wrong
>  but in about half of the time I find ghci (as a
>  debugger) almost useless. The reason is the limited
>  way it can resolve identifiers. I can examine
>  the free variables in the selected expression and
>  nothing else. Well, I *think* just sometimes I can
>  examine few more variables. But if it happens at
>  all it is rare.
> Is there a way to make ghci recognize all the variables
>  which could be visible in the selected expression?
>  By "could be visible" I mean they are in scope and
>  can be used in the expression if I would edit the
>  source code.

We thought about this when working on the debugger, and the problem is that 
to make the debugger retain all the variables that are in scope rather than 
just free in the expression adds a lot of overhead, and it fundamentally 
changes the structure of the generated code: everything becomes recursive, 
for one thing.  Well, perhaps you could omit all the recursive references 
(except the ones that are also free?), but there would still be a lot of 
overhead due to having to retain all those extra references.

It also risks creating serious space leaks, by retaining references to 
things that the program would normally discard.

Fortunately it's usually easy to work around the limitation, just by adding 
extra references to your code, e.g. in a let expression that isn't used.


More information about the Glasgow-haskell-users mailing list