[Haskell-cafe] GHC magic optimization ?

Henning Thielemann lemming at henning-thielemann.de
Thu Dec 3 10:40:32 EST 2009

On Thu, 3 Dec 2009, Emmanuel CHANTREAU wrote:

> Hello
> One thing is magic for me: how GHC can know what function results to
> remember and what results can be forgotten ?
> Is it just a stupid buffer algorithm or is there some mathematics
> truths behind this ?

Although it is not required by the Haskell 98 report, the 'let' expression 
usually stores variable values (sharing) and top-level constants are also 
stored. I wonder how much of currently existing Haskell code would still 
work, if this would be changed, since this behavior is essential for 
memory usage and speed.
  If you want to cache function results, see:

More information about the Haskell-Cafe mailing list