The stm-io-hooks package

This library provides an STM monad with commit and retry IO hooks.
A retry-action is run (once) if the transaction retries, while commit-actions are
executed iff the transaction commits. The library also gives some atomicity
guarantees for commit-actions:

When a TVar is modified in a transaction and this transaction commits,
the update remains invisible to other threads until the corresponding
onCommit action is run.

If the onCommit action throws an exception, the original values of
the modified TVars are restored.