[Haskell-cafe] Is unsafePerformIO safe here?

John Ky newhoggy at gmail.com
Sun Dec 7 19:28:56 EST 2008


Hi,

Is the following safe?

moo :: TVar Int
moo = unsafePerformIO $ newTVarIO 1

I'm interested in writing a stateful application, and I wanted to start with
writing some IO functions that did stuff on some state and then test them
over long periods of time in GHCi.

I was worried I might be depending on some guarantees that aren't actually
there, like moo being discarded and recreated inbetween invocations of
different functions.

Thanks,

-John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081208/0956c07f/attachment.htm


More information about the Haskell-Cafe mailing list