[Haskell-cafe] Thunks

Bernie Pope florbitous at gmail.com
Fri Oct 15 02:54:21 EDT 2010

On 15 October 2010 07:53, Mihai Maruseac <mihai.maruseac at gmail.com> wrote:
> Hi,
> Is there a way to determine the order in which thunks are created and
> expanded/evaluated in Haskell (GHC)? I'm looking mainly at some
> existing interface but if there is only something in the GHC source it
> will suffice.

You can use side effects to observe the order of evaluation, by
wrapping observed expressions (thunks) with some IO computation inside
unsafePerformIO. This is roughly what HOOD does, and it can be used to
provide some clues about evaluation order, and maybe even GHood can
help you visualise it. I've no idea if they work at the moment, but
Hood and GHood are available on Hackage.

You have to be careful of "observer effects" whereby the observation
wrappers change the evaluation order of the observed code.


More information about the Haskell-Cafe mailing list