
On Sat, Jun 11, 2005 at 01:55:57AM +0200, Thomas Jäger wrote:
Just looking at the documentation for System.IO.unsafeInterleaveIO, what exactly is unsafe about it?
It can create "pure values" that trigger side effects during their evaluation. This can be abused to do IO outside of an IO monad (actually, hGetContents can already be used for that purpose).
In the worst case, it can even crash the RTS:
import Control.Concurrent.STM import System.IO.Unsafe
main :: IO () main = atomically =<< unsafeInterleaveIO (atomically $ return $ return ())
Thomas
Stares at a core-dump. I wonder whether this would be worth a bug-report, or perhaps a warning in STM's docs about (understandable) undefined behaviour in this case. Interestingly, Tomasz Zielonka's FakeSTM [1] survives it. Groeten, Remi [1] http://www.haskell.org/pipermail/haskell-cafe/2005-March/009389.html darcs get http://www.uncurry.com/repos/FakeSTM/ -- Nobody can be exactly like me. Even I have trouble doing it.