[Haskell-cafe] MVar which can not be null ?

Tim Docker tim at dockerz.net
Mon Mar 18 10:15:02 CET 2013


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130318/8cf710fa/attachment-0001.htm>


More information about the Haskell-Cafe mailing list