> Can someone help me understand how this works? I've been > reading the paper "Asynchronous Exceptions in Haskell". This > gives a combinator > > finally :: IO a -> IO b -> IO s > > finally a b = > block (do { > r <- catch (unblock a) (\e -> do { b; throw e }); > b; > return r; }) > > Now suppose we have > > finally (putStrLn "Test Started") (putStrLn "Test Terminated") > > then looking at the semantics, putStrLn can become stuck and > therefore can be interrupted. So the interrupt could occur > whilst "Test Terminated" is being output and we could end up with > > Test Started > Test Term > > Is this what could happen? If so, is there a way of making > sure that "Test Terminated" is output?
Yes, that's correct. putStrLn is interruptible, so you can't force it to run to completion - to do so would introduce a possible deadlock. However, I agree that sometimes you really want to be able to do this, so perhaps we need another form of 'block' which doesn't allow *any* exceptions to be delivered, for those times when you know that the time spent waiting in an interruptible operation is going to be bounded. Cheers, Simon _______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell