
18 Apr
2001
18 Apr
'01
9:15 p.m.
Johannes Waldmann writes: | Thank you, Marcin. | | Your reply seems to imply that the structure | of the program I posted was basically OK? Another way appears as an example in Tackling The Awkward Squad (in the Using Asynchronous Exceptions section). It's a bit more liberal in its use of threads, doing forkIO twice within parIO, but the overall effect is pretty similar to your function's. timeout :: Int -> IO a -> IO (Maybe a) timeout n a = parIO (do { r <- a; return (Just r) }) (do { threadDelay n; return Nothing })