module Try.Exceptions.Theory where
Exceptions
- Safe exception handling
- Types of exceptions:
synchronous- generated inIO, thrown inside a single thread. Allowrecoveryandcleanupasynchronous- generated from outside a thread. Allowcleanup, butno recoveryimpure- generated in a pure code, thrown when a thunk gets evaluated.- Example:
error
- Example:
- Types of exceptions:
- [Exceptions and concurrency] - YT
- use [safe-exceptions]
From Haskell in Depth (Chapter 7)
- Avoid using exceptions when possible
- Due to laziness, an exception in an expression doesn't happen until that expression gets evaluated.
- A thread can be killed by other threads or the runtime system (due to memory exhaustion, etc.)
- Types of exceptions:
programmable- used in pure monad stacks (e.g.,
ExceptT)
- used in pure monad stacks (e.g.,
extensible- Extensions thrown anywhere, caught only in
IO - Supported by the GHC runtime system
impreciseexceptions - thrown in pure code, order unspecified by the runtime system- All exceptions have an instance of
Exceptionand are values of theSomeExceptiontype
- Extensions thrown anywhere, caught only in
- packages -
exceptions,safe-exceptions