Add throwSTM and generalize catchSTM
Currently the only way to throw an exception in an STM transaction is via throw. The IO monad has the throwIO function which guarantees ordering with respect to other IO actions. It would be nice to have a similar function for the STM monad:
throwSTM :: Exception e => e -> STM a
Catching exceptions in the IO monad can be done with catch:
catch :: Exception e => IO a -> e -> IO a -> IO a
Catching exception in the STM monad can be done with catchSTM:
catchSTM :: STM a -> (SomeException -> STM a) -> STM a
However, it would be nice to generalize this function to any exception:
catchSTM :: Exception e => STM a -> (e -> STM a) -> STM a
This makes it consistent with the IO catch function and allows packages like: exception-monads-fd/tf to define instances for MonadException.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | libraries (other) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |