-- | Utilities for Data.IORef. module Agda.Utils.IORef ( module Data.IORef , module Agda.Utils.IORef ) where import Data.IORef -- | Read 'IORef', modify it strictly, and return old value. readModifyIORef' :: IORef a -> (a -> a) -> IO a readModifyIORef' :: forall a. IORef a -> (a -> a) -> IO a readModifyIORef' IORef a ref a -> a f = do a x <- forall a. IORef a -> IO a readIORef IORef a ref forall a. IORef a -> a -> IO () writeIORef IORef a ref forall a b. (a -> b) -> a -> b $! a -> a f a x forall (m :: * -> *) a. Monad m => a -> m a return a x