[Haskell-cafe] How to debug GHC

Bernard Pope bjpop at cs.mu.OZ.AU
Wed Apr 27 03:15:30 EDT 2005

On Wed, 2005-04-27 at 07:45 +0200, Ketil Malde wrote:
> > [I want to know] who called who all the way from "main" to "head",
> > because the key function is going to be one somewhere in the middle.
> Perhaps.  I am told stack backtraces are difficult with non-strict
> semantics.

This is true, at least for _lazy_ implementations of non-strict

The reason is that the (graph) context in which a function application
is constructed can be very different to the context in which it is

Partial application of functions introduces a similar problem.

This is not a problem in first-order eager languages because the
construction of a (saturated) function application is followed
immediately by its reduction. Thus the contexts of construction and
reduction are the same.

Debugging tools like Hat, Freya and Buddha, "remember" the
construction context of an application, so you can get call graphs that
reflect the dependencies between symbols in the source code. Thus you
can construct a meaningful backtrace etc. Actually, Hat remembers quite
a bit more context than Freya and Buddha, but that's another story.

Another way around the problem is to opt for a non-lazy, but still
non-strict, evaluation order, such as optimistic evaluation. Think:
mostly eager, with the occasional suspension. HsDebug is based on this
idea. (Though it doesn't solve the problem with partial applications.)


More information about the Haskell-Cafe mailing list