haskell-issues icon indicating copy to clipboard operation
haskell-issues copied to clipboard

Add monadic IORef functions (e.g. atomicModifyIORefM)

Open Gurkenglas opened this issue 8 years ago • 2 comments

atomicModifyIORef :: IORef a -> (a -> (a, b)) -> IO b into atomicModifyIORefM :: MonadIO m => IORef a -> (a -> m (b, a)) -> m b and similarly for nearby functions.

runIORefStateT :: MonadIO m => IORef s -> StateT s m b -> m b or perhaps flipped would put the full power of Control.Monad.Trans.State behind this.

Not sure how to prefix this, when base should not have an mtl dependency... but at the very least, IORef a -> (a -> IO (b, a)) -> IO b is overdue.

Gurkenglas avatar Mar 19 '16 21:03 Gurkenglas