
On Tue, Jan 17, 2012 at 3:20 PM, David Barbour
I'd say use of asynchronous exceptions should be a last resort. ...
I agree. However, network libraries in Haskell (e.g. Handle, Network.TLS) generally don't provide the primitives needed to do that on the receiving end. For example, if a thread is blocked on hGetBuf, it cannot also wait on a signal telling it to stop. Since hClose on the same handle will block until the hGetBuf is done, the only way to stop reading from the handle is to throw an asynchronous exception at the hGetBuf thread. Worse, since there is no threadWaitReadHandle :: Handle -> IO (), there's no way to guarantee that hGetBuf will not be interrupted in the middle of receiving a packet. From an application perspective, this invalidates subsequent retrievals unless the protocol is self-synchronizing. -Joey