Weak pointers and STM

Sterling Clover s.clover at gmail.com
Tue Dec 2 21:10:08 EST 2008

> basically, what would be really nice is if there were something like
> > registerCommitIO :: IO () -> STM ()
> where all IO actions registered with this function (within an atomically
> block) are executed exactly once if and only if the atomically block
> commits. The IO action is not run within the STM block, notably
>        atomically $ do foo; registerCommitIO bar; baz
> is equivalent to
>        atomically (do foo; baz) >> bar

This is easy enough to whip up with a monad transformer over STM. I think
the AdvSTM implementations [1] are rather complicated and heavyweight, but
they give a general picture of how to proceed. A simple ReaderT with a TChan
should do the trick quite nicely.

[1] http://www.haskell.org/haskellwiki/New_monads/MonadAdvSTM


p.s. as for the issue of the Ord instance, I wonder if tsWord needs to be a
TVar or if an IVar or IORef would be sufficient?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20081202/0f0fdfbf/attachment-0001.htm

More information about the Glasgow-haskell-users mailing list