{-# LANGUAGE CPP #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE FlexibleContexts #-}
#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Trustworthy #-}
#endif
module Data.IORef.Lifted
( IORef
, newIORef
, readIORef
, writeIORef
, modifyIORef
#if MIN_VERSION_base(4,6,0)
, modifyIORef'
#endif
, atomicModifyIORef
#if MIN_VERSION_base(4,6,0)
, atomicModifyIORef'
, atomicWriteIORef
#endif
, mkWeakIORef
) where
import Data.IORef ( IORef )
import qualified Data.IORef as R
import System.IO ( IO )
import System.Mem.Weak ( Weak )
import Prelude ( (.) )
import Control.Monad.Base ( MonadBase, liftBase )
import Control.Monad.Trans.Control ( MonadBaseControl, liftBaseDiscard )
#include "inlinable.h"
newIORef :: MonadBase IO m => a -> m (IORef a)
newIORef = liftBase . R.newIORef
readIORef :: MonadBase IO m => IORef a -> m a
readIORef = liftBase . R.readIORef
writeIORef :: MonadBase IO m => IORef a -> a -> m ()
writeIORef r = liftBase . R.writeIORef r
modifyIORef :: MonadBase IO m => IORef a -> (a -> a) -> m ()
modifyIORef r = liftBase . R.modifyIORef r
atomicModifyIORef :: MonadBase IO m => IORef a -> (a -> (a, b)) -> m b
atomicModifyIORef r = liftBase . R.atomicModifyIORef r
#if MIN_VERSION_base(4,6,0)
modifyIORef' :: MonadBase IO m => IORef a -> (a -> a) -> m ()
modifyIORef' r = liftBase . R.modifyIORef' r
atomicModifyIORef' :: MonadBase IO m => IORef a -> (a -> (a, b)) -> m b
atomicModifyIORef' r = liftBase . R.atomicModifyIORef' r
atomicWriteIORef :: MonadBase IO m => IORef a -> a -> m ()
atomicWriteIORef r = liftBase . R.atomicWriteIORef r
#endif
mkWeakIORef :: MonadBaseControl IO m => IORef a -> m () -> m (Weak (IORef a))
mkWeakIORef = liftBaseDiscard . R.mkWeakIORef