18 Mar
2013
18 Mar
'13
9:15 a.m.
On 18/03/13 19:07, s9gf4ult wrote:
nor STM, becuase IO is not acceptable inside STM transaction.
I just need some thread-safe blocking variable like MVar
modifyMVar :: MVar <http://hackage.haskell.org/packages/archive/base/4.6.0.1/doc/html/Control-Concurrent-MVar.html#t:MVar> a -> (a -> IO <http://hackage.haskell.org/packages/archive/base/4.6.0.1/doc/html/System-IO.html#t:IO> (a, b)) -> IO <http://hackage.haskell.org/packages/archive/base/4.6.0.1/doc/html/System-IO.html#t:IO> b
Whilst it's true that IO cannot be performed within an STM action, a common pattern is to return the necessary IO action from the STM action, and then run it once the STM transaction has completed successfully. Tim