I'm wondering about the optimization of ghc. I thought that since
functions are pure in haskell, compiler can/do factorize common
subexpressions when it optimizes a code. But the result of
the following
experiment looks negative; g 10 100 is caluculated twice.
Am I missing something?
My original mail might be misleading, but I didn't mean that I want to
rely on the optimization to make the program work.
I just thought If I could expect such an optimization to be performed,
I would not need to rewrite everytime
func (g x) (g x) -- g x = unsafeperformIO $ do {...}
to
let h =
G'day all.
Quoting Koji Nakahara [EMAIL PROTECTED]:
I'm wondering about the optimization of ghc. I thought that since
functions are pure in haskell, compiler can/do factorize common
subexpressions when it optimizes a code.
The short answer is no. While the optimisation preserves semantics,
On Wed, 3 Dec 2003 03:29:14 +0900
Koji Nakahara [EMAIL PROTECTED] wrote:
I want to use some C functions from haskell each of which is not pure
but the result of their sequential combination is pure. I'm planning
to write some functions like g above(but more complex and actually
pure) and