Asynchronous Exceptions

Steinitz, Dominic J Dominic.J.Steinitz@BritishAirways.com
23 Nov 2001 08:23:51 Z


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?

Dominic.

-------------------------------------------------------------------------------------------------
To receive our special fares directly by email, register at http://www.britishairways.com/registration