I have been using Haskell’s STM library and I really like the ability to compose transactions and the general “you-can’t-get-this-wrong” nature of STM.
For good reason, STM does not allow IO actions within a transaction. There is no way to retry an IO action. (insert Launch missiles reference here). Database transactions on the other hand do have some atomicity guarantees that are very similar. Is there an accepted way to use the two together?
Interleaving different sorts of transactions into a single transaction notion is called “transactional boosting” and there isn’t a great way to do it in Haskell’s STM at the moment. There is, however, a way to build up actions to be performed only on commit or only on retry: http://hackage.haskell.org/package/stm-io-hooks
Additionally, you could try the twilight-stm project, which provides an an explicit “twilight” between transactions ending and actual commit. As far as I know, the code provided is more of a reference implementation than one tuned for performance, however: http://proglang.informatik.uni-freiburg.de/projects/twilight/
Nonetheless, depending on your application, it may turn out to be plenty-fast for your purposes.