    -- | 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 <- IORef a -> IO a
    forall a. IORef a -> IO a
    readIORef IORef a
    ref
        IORef a -> a -> IO ()
    forall a. IORef a -> a -> IO ()
    writeIORef IORef a
    ref (a -> IO ()) -> a -> IO ()
    forall a b. (a -> b) -> a -> b
    $! a -> a
    f a
    x
        a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return a
    x