unliftio-0.2.25.0: The MonadUnliftIO typeclass for unlifting monads to IO (batteries included)

Safe Haskell | Safe-Inferred
Language | Haskell2010

UnliftIO.IORef

Description

Unlifted Data.IORef.

Since: 0.1.0.0

Synopsis

- data IORef a
- newIORef :: MonadIO m => a -> m (IORef a)
- readIORef :: MonadIO m => IORef a -> m a
- writeIORef :: MonadIO m => IORef a -> a -> m ()
- modifyIORef :: MonadIO m => IORef a -> (a -> a) -> m ()
- modifyIORef' :: MonadIO m => IORef a -> (a -> a) -> m ()
- atomicModifyIORef :: MonadIO m => IORef a -> (a -> (a, b)) -> m b
- atomicModifyIORef' :: MonadIO m => IORef a -> (a -> (a, b)) -> m b
- atomicWriteIORef :: MonadIO m => IORef a -> a -> m ()
- mkWeakIORef :: MonadUnliftIO m => IORef a -> m () -> m (Weak (IORef a))

# Documentation

data IORef a #

A mutable variable in the `IO` monad.

    >>> import GHC.Internal.Data.IORef
    >>> r <- newIORef 0
    >>> readIORef r
    0
    >>> writeIORef r 1
    >>> readIORef r
    1
    >>> atomicWriteIORef r 2
    >>> readIORef r
    2
    >>> modifyIORef' r (+ 1)
    >>> readIORef r
    3
    >>> atomicModifyIORef' r (\a -> (a + 1, ()))
    >>> readIORef r
    4

See also `STRef` and `MVar`.

#### Instances

Instances details

NFData1 IORef | Since: deepseq-1.4.3.0
Instance details Defined in Control.DeepSeq Methods liftRnf :: (a -> ()) -> IORef a -> () #
NFData (IORef a) | NOTE: Only strict in the reference and not the referenced value. Since: deepseq-1.4.2.0
Instance details Defined in Control.DeepSeq Methods rnf :: IORef a -> () #
Eq (IORef a) | Pointer equality. @since base-4.0.0.0
Instance details Defined in GHC.Internal.IORef Methods (==) :: IORef a -> IORef a -> Bool # (/=) :: IORef a -> IORef a -> Bool #

newIORef :: MonadIO m => a -> m (IORef a) #

Lifted `newIORef`.

Since: 0.1.0.0

readIORef :: MonadIO m => IORef a -> m a #

Lifted `readIORef`.

Since: 0.1.0.0

writeIORef :: MonadIO m => IORef a -> a -> m () #

Lifted `writeIORef`.

Since: 0.1.0.0

modifyIORef :: MonadIO m => IORef a -> (a -> a) -> m () #

Lifted `modifyIORef`.

Since: 0.1.0.0

modifyIORef' :: MonadIO m => IORef a -> (a -> a) -> m () #

Lifted `modifyIORef'`.

Since: 0.1.0.0

atomicModifyIORef :: MonadIO m => IORef a -> (a -> (a, b)) -> m b #

Lifted `atomicModifyIORef`.

Since: 0.1.0.0

atomicModifyIORef' :: MonadIO m => IORef a -> (a -> (a, b)) -> m b #

Lifted `atomicModifyIORef'`.

Since: 0.1.0.0

atomicWriteIORef :: MonadIO m => IORef a -> a -> m () #

Lifted `atomicWriteIORef`.

Since: 0.1.0.0

mkWeakIORef :: MonadUnliftIO m => IORef a -> m () -> m (Weak (IORef a)) #

Unlifted `mkWeakIORef`.

Since: 0.1.0.0