[Haskell-cafe] what does @ mean?.....

Jules Bean jules at jellybean.co.uk
Fri Dec 28 11:35:17 EST 2007


Serge LE HUITOUZE wrote:
> I tend to believe that the '@' notation is mere syntactic sugar.
> Indeed, it seems to me that Haskell compilers need not to be very clever to
> share the identical sub-expressions, for one very simple reason implied by
> Haskell semantics: referential transparency.
> 
> Am I right, or am I missing something?

You are missing that modifying a program in a way which adds sharing can 
have disastrous performance effects.

In particular, adding sharing can stop something being GCed, which can 
convert an algorithm which runs in linear time and constant space to one 
which runs in linear space (and therefore, perhaps, quadratic time).

Therefore compilers have to be conservative about adding sharing.

In general, sharing in GHC-compiled programs is specified rather 
explicitly: sharing is naming, so things which are names (let-bound or 
pattern-bound) are guaranteed shared and normally nothing else.

You can *imagine* a compiler being cleverer about this. It turns out to 
be an interesting but hard problem.

Jules


More information about the Haskell-Cafe mailing list