A Software Transactional Memory (STM) monad with IO hooks