[Haskell-cafe] Re: CAF's in Haskell

Neil Mitchell ndmitchell at gmail.com
Wed Dec 26 13:16:34 EST 2007


> > Are CAF's specified in the Haskell report? I couldn't find them mentioned.
> CAF is a term of art. If you define
> fred = 2 + 2
> that's a CAF.

I should have been more precise with my question. Given the code:

fred = 2 + 2

bob = fred + fred

In a Haskell implementation fred would be evaluated once to 4, then
used twice. The 2+2 would only happen once (ignore defaulting and
overloaded numerics for now).

Is this sharing mandated by the standard? (I don't think so) Is there
some paper that describes why this is desirable, and gives any detail?

> > If not, why do all Haskell compilers support them?
> How could they not? I'm not sure I understand your question.

Do all Haskell compilers support the sharing.



More information about the Haskell-Cafe mailing list