[Haskell-cafe] Re: Eta-expansion destroys memoization?

Bertram Felgenhauer bertram.felgenhauer at googlemail.com
Tue Oct 12 04:34:15 EDT 2010

Simon Marlow wrote:
> Interesting.  You're absolutely right, GHC doesn't respect the
> report, on something as basic as sections!  The translation we use
> is
>   (e op)  ==>  (op) e
> once upon a time, when the translation in the report was originally
> written (before seq was added) this would have been exactly
> identical to \x -> e op x, so the definition in the report was
> probably used for consistency with left sections.
> We could make GHC respect the report, but we'd have to use
>   (e op)  ==>  let z = e in \x -> z op x
> to retain sharing without relying on full laziness.

We should keep in mind that this was changed deliberately in ghc 6.6,
in order to support "postfix" operators.


The motivating example was the factorial operator which can currently
be written as  (n !)  in ghc-Haskell.



More information about the Haskell-Cafe mailing list