When is unsafeInterleaveIO unsafe?
问题 Unlike other unsafe* operations, the documentation for unsafeInterleaveIO is not very clear about its possible pitfalls. So exactly when is it unsafe? I would like to know the condition for both parallel/concurrent and the single threaded usage. More specifically, are the two functions in the following code semantically equivalent? If not, when and how? joinIO :: IO a -> (a -> IO b) -> IO b joinIO a f = do !x <- a !x' <- f x return x' joinIO':: IO a -> (a -> IO b) -> IO b joinIO' a f = do !x