simple CSE?

Simon Peyton-Jones simonpj at
Tue Apr 1 07:21:29 EDT 2008

Not reliably, no.  GHC's current CSE is rather opportunistic: we take the opportunity if it's presented in the form
let x = e in let y = e in ....

A proper CSE pass would be a nice, containable, project.


From: glasgow-haskell-users-bounces at [mailto:glasgow-haskell-users-bounces at] On Behalf Of Conal Elliott
Sent: 29 March 2008 01:53
To: glasgow-haskell-users at
Subject: simple CSE?

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