Taral wrote:
On 12/4/07, Simon Marlow <[EMAIL PROTECTED]> wrote:
do
x <- newIVar
let y = readIVar x
writeIVar x 3
print y
(I wrote the let to better illustrate the problem, of course you can inline
y if you want). Now suppose the compiler decided to evaluate y before the
writeIVar. What's to prevent it doing that?
Look at the translation:
newIVar >>= (\x -> let y = readIVar x in writeIVar x 3 >> print y)
y can't be floated out because it depends on x.
y doesn't need to be floated out, just evaluated eagerly.
Cheers,
Simon
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe