simple CSE?

Conal Elliott conal at
Fri Mar 28 21:53:15 EDT 2008

I'd like to know if it's possible to get GHC to perform some simple CSE for
function-level programming.  Here's a simple example:

    liftA2 (*) sin sin :: Double -> Double

which inlines and simplifies to

  \ t -> sin t * sin t

A more realistic, equivalent, example:

    let b = sin <$> id in liftA2 (*) b b

Can GHC be nudged into computing 'sin t' once rather than twice?

Thanks,  - Conal
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Glasgow-haskell-users mailing list