On 14 December 2005 10:11, Joel Reymont wrote: > I'm a bit lost in the discussion. Why do I need -fno-cse and how do I > seq at the top-level? > > On Dec 14, 2005, at 10:05 AM, Tomasz Zielonka wrote: > >> On Wed, Dec 14, 2005 at 10:03:42AM -0000, Simon Marlow wrote: >>> Well sure, but it's only a temporary problem. And you also have to >>> tell them to use {-# NOINLINE #-} and -fno-cse :-) >> >> -fno-cse is also neccesary? Oops, I didn't know that. Can I simply >> place it in {-# OPTIONS -fno-cse #-} ?
Suppose you create two top-level IORefs with the same type, like this: var1 = unsafePerformIO $ newIORef 0 var2 = unsafePerformIO $ newIORef 0 GHC's CSE optimisation will common these up - after all, it's the same expression, so it must yield the same result, right? To turn this off, we use -fno-cse. It's good practice to use -fno-cse whenever you use top-level mutable objects of any kind. You can put it in the source file: {-# OPTIONS_GHC -fno-cse #-} at the top of your file. Cheers, Simon _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe