[Haskell-cafe] Is there a way to see the equation reduction?

Claus Reinke claus.reinke at talk21.com
Wed Apr 1 07:07:07 EDT 2009

>> But I am more interested in seeing the expansion and reduction that
>> the execution encounters as it lazily evaluates the function.
> Have you tried GHood?

>    http://www.cs.kent.ac.uk/people/staff/cr3/toolbox/haskell/GHood/

> It is a bit like the recently-released Vacuum visualiser for data
> structures, except that it also animates the reduction sequence.
> (Have a look at some of the online examples - you can view the reduction
> steps right there in your web browser.)

Ahem. While I do recommend GHood for getting animated visual
insights into what your program is doing, 

    *GHood does not animate reductions*
        for instance, the steps of 'id id id ()' reducing will not be visible
        as such, though by observing the first 'id', you would be able 
        to see all the 'id's being applied to their parameters and yielding
        their results (and you could add further probes)

    *GHood animates observations*
        - when the usage contexts starts looking through an observe
            probe for the data behind the probe (demand goes in)
        - when the data behind a probe has been reduced to produce
            a further level of WHNF (data goes out)

Non-strict evaluation means that things won't be reduced unless
that is forced by observation but, nevertheless, the two are not
the same, they complement each other. Also, GHood/Hood do 
not observe sharing or when data is freed, which might be 
relevant for the example. On the positive side, observations 
can be targetted, so one can put small probes into large projects, 
and observations are very relevant for (relative) strictness issues.

It would be nice if an animation visualizer could be built on top 
of Vacuum, just as GHood was built on top of Hood. Of course, 
I'd really like to be able to follow reductions textually as well, 
in a combination of editor/ide/GHCi. It was shown long ago 
that this needn't be in conflict with efficient implementation,
such as compiled graph reduction (as I might have mentioned

I doubt that the ancient code still installs properly, but the old 
pages or pi-RED/KiR are still there(*), so anyone building a 
new Haskell implementation could look at user's guide and 
papers for inspiration, but it would be difficult to add after 
the fact to an implementation as complex as GHC.


(*) http://www.informatik.uni-kiel.de/~base/

More information about the Haskell-Cafe mailing list