[Haskell-cafe] Avoid sharing
mail at joachim-breitner.de
Mon Nov 7 21:34:23 UTC 2016
Am Montag, den 07.11.2016, 16:00 -0500 schrieb Brandon Allbery:
> It's not specified in any standard, but ghc will only share something
> that is directly bound. There is no sensible way to determine sharing
> automatically that will do what everyone expects, so ghc doesn't try:
> the programmer is expected to use bindings to specify sharing.
that is not true. GHC applies „common subexpression elimination“, and
this optimization pass will likely sum up the two occurrences of
In places online it says that only code like
> let x = e in .... let y = e in ....
would be CSEd. But reading the code (CSE.hs) I conclude that also
> let x = e in .... foo e ....
would get CSEd, which includes the code posted by Michael Roth.
Furthermore, the FloatOut pass may turn
> … foo e …
> let x = e in … foo x …
under certain circumstance, so even a limited form of CSE can apply
In the end, only looking at the Core of a concrete program can help to
answer these questions.
Joachim “nomeata” Breitner
mail at joachim-breitner.de • https://www.joachim-breitner.de/
XMPP: nomeata at joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F
Debian Developer: nomeata at debian.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 801 bytes
Desc: This is a digitally signed message part
More information about the Haskell-Cafe