An asynchronous exception is raised by code outside the affected thread to change that thread’s control flow. Haskell represents these runtime events with the AsyncException type. section 14.4.1 section 14.5
AsyncException has four constructors:
- StackOverflow is raised when a thread exceeds its stack-size limit. section 14.4.1
- HeapOverflow is raised when the program’s heap reaches its limit. section 14.4.1
- ThreadKilled stops a thread, usually after another thread throws the exception to it. section 14.4.1
- UserInterrupt represents cancellation by the user, such as pressing Ctrl-C. section 14.4.1
Catching UserInterrupt is useful when an operation must undo partial work. A file copy can leave a partially copied file behind, so the handler removes that file before rethrowing the interruption. section 14.4.1
Cleaning up an interrupted copy
Use catchJust with a predicate that selects UserInterrupt, run the copy action, remove the destination in the handler, and rethrow UserInterrupt.

