relude-0.7.0.0: Safe, performant, user-friendly and lightweight Haskell Standard Library
Copyright(c) 2016 Stephen Diehl
(c) 2016-2018 Serokell
(c) 2018-2020 Kowainik
LicenseMIT
MaintainerKowainik <xrom.xkov@gmail.com>
StabilityStable
PortabilityPortable
Safe HaskellSafe
LanguageHaskell2010

Relude.Lifted.IORef

Description

Lifted reexports from Data.IORef module.

Synopsis

Documentation

data IORef a #

A mutable variable in the IO monad

Instances

Instances details
NFData1 IORef

Since: deepseq-1.4.3.0

Instance details

Defined in Control.DeepSeq

Methods

liftRnf :: (a -> ()) -> IORef a -> () #

Eq (IORef a)

Pointer equality.

Since: base-4.0.0.0

Instance details

Defined in GHC.IORef

Methods

(==) :: IORef a -> IORef a -> Bool #

(/=) :: IORef a -> IORef a -> Bool #

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 -> () #

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

Lifted version of atomicModifyIORef.

>>> ref <- newIORef 42
>>> atomicModifyIORef ref (\a -> (a, a + 3))
45
>>> readIORef ref
42

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

Lifted version of atomicModifyIORef'.

>>> ref <- newIORef 42
>>> atomicModifyIORef' ref (\a -> (a, a + 3))
45
>>> readIORef ref
42

atomicModifyIORef_ :: MonadIO m => IORef a -> (a -> a) -> m () Source #

Version of atomicModifyIORef that discards return value. Useful when you want to update IORef but not interested in the returning result.

>>> ref <- newIORef 42
>>> atomicModifyIORef_ ref (`div` 2)
>>> readIORef ref
21

Since: 0.7.0.0

atomicModifyIORef'_ :: MonadIO m => IORef a -> (a -> a) -> m () Source #

Version of atomicModifyIORef' that discards return value. Useful when you want to update IORef but not interested in the returning result.

>>> ref <- newIORef 42
>>> atomicModifyIORef'_ ref (`div` 2)
>>> readIORef ref
21

Since: 0.7.0.0

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

Lifted version of atomicWriteIORef.

>>> ref <- newIORef 42
>>> atomicWriteIORef ref 45
>>> readIORef ref
45

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

Lifted version of modifyIORef.

>>> ref <- newIORef 42
>>> modifyIORef ref (\a -> a + 6)
>>> readIORef ref
48

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

Lifted version of modifyIORef'.

>>> ref <- newIORef 42
>>> modifyIORef' ref (\a -> a + 3)
>>> readIORef ref
45

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

Lifted version of newIORef.

>>> ref <- newIORef False
>>> :t ref
ref :: IORef Bool

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

Lifted version of readIORef.

>>> ref <- newIORef 42
>>> readIORef ref
42

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

Lifted version of writeIORef.

>>> ref <- newIORef 42
>>> writeIORef ref 43
>>> readIORef ref
43