Hi,
if i say:
foo = do putStrLn "a" unsafeInterleaveIO (putStrLn "b" >> putStrLn "c") putStrLn "d"
is it guarenteed that nothing will happen between putting "b" and "c"? that is, while the place/time at which the (putStrLn "b" >> putStrLn "c") is unspecified, is it the case that the whole thing will be done at once?
In your example it's more or less guaranteed that putting "b" and "c" will never happen, because the result of the combinated IO action isn't demanded. I think, a better example would be: foo = do putStrLn "a" res <- unsafeInterleaveIO (getLine >>= \c -> getLine >>= \d -> return (c++d)) putStrLn "d" putStrLn res Here the result 'res' is demanded after printing "d", and the IO action (getLine >>= \c -> getLine >>= \d -> return (c++d)) is performed after printing "d", when the result is demanded. I don't know the answer to your main question, but if you translate the combined monadic action down to core language you'll get some nested case-expressions, and I don't think that a correct program transformation could destroy the order of them (which would be necessary to put another IO action between the others). David Sabel ----------- JWGU Frankfurt