
You can't. CSE (common subexpression elimination) will replace any occurances of 'newState 0' in a function body with the same value. In short: don't use upIO :) If I'm wrong, someone will correct me. But expect a few "what are you trying to do" email messages or people suggesting implicit paremeters or monad wrappers (in fact, count this as the first of said emails). - Hal -- Hal Daume III "Computer science is no more about computers | hdaume@isi.edu than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume On Mon, 18 Nov 2002, Nicolas Oury wrote:
I want to write something like
type State a = IORef a
newState :: a -> State a newState v = unsafePerformIO (newIORef v)
But I don't want the compileer to inline this nor to inline any application of this.
{#NOINLINE newState#}
But how can I stop this function to be inlined when applied for example : .... let x = newState 0 in {... code where x is used twice ...}
How to be sure that x isn't inlined and that all occurences of x are pointing to the same memory place ?
Best regards, Nicolas Oury
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users