
10 Jun
2005
10 Jun
'05
11:55 p.m.
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