| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Effects.IORef
Description
Provides the MonadIORef class.
Since: 0.1
Synopsis
- class Monad m => MonadIORef (m :: Type -> Type) where
- newIORef :: HasCallStack => a -> m (IORef a)
- newIORef' :: HasCallStack => a -> m (IORef a)
- readIORef :: HasCallStack => IORef a -> m a
- readIORef' :: HasCallStack => IORef a -> m a
- writeIORef :: HasCallStack => IORef a -> a -> m ()
- writeIORef' :: HasCallStack => IORef a -> a -> m ()
- atomicWriteIORef :: HasCallStack => IORef a -> a -> m ()
- atomicWriteIORef' :: HasCallStack => IORef a -> a -> m ()
- modifyIORef :: HasCallStack => IORef a -> (a -> a) -> m ()
- modifyIORef' :: HasCallStack => IORef a -> (a -> a) -> m ()
- atomicModifyIORef :: HasCallStack => IORef a -> (a -> (a, b)) -> m b
- atomicModifyIORef' :: HasCallStack => IORef a -> (a -> (a, b)) -> m b
- atomicModifyIORef_ :: (HasCallStack, MonadIORef m) => IORef a -> (a -> a) -> m ()
- atomicModifyIORef'_ :: (HasCallStack, MonadIORef m) => IORef a -> (a -> a) -> m ()
- data IORef a
Effect
class Monad m => MonadIORef (m :: Type -> Type) where Source #
IORef effect.
Since: 0.1
Methods
newIORef :: HasCallStack => a -> m (IORef a) Source #
Lifted newIORef.
Since: 0.1
newIORef' :: HasCallStack => a -> m (IORef a) Source #
Evaluates a to WHNF then calls newIORef.
Since: 0.1
readIORef :: HasCallStack => IORef a -> m a Source #
Lifted readIORef.
Since: 0.1
readIORef' :: HasCallStack => IORef a -> m a Source #
Evaluates the result of readIORef to WHNF.
Since: 0.1
writeIORef :: HasCallStack => IORef a -> a -> m () Source #
Lifted writeIORef.
Since: 0.1
writeIORef' :: HasCallStack => IORef a -> a -> m () Source #
Evaluates a to WHNF before calling writeIORef.
Since: 0.1
atomicWriteIORef :: HasCallStack => IORef a -> a -> m () Source #
Lifted atomicWriteIORef.
Since: 0.1
atomicWriteIORef' :: HasCallStack => IORef a -> a -> m () Source #
Evaluates a to WHNF before calling atomicWriteIORef.
Since: 0.1
modifyIORef :: HasCallStack => IORef a -> (a -> a) -> m () Source #
Lifted modifyIORef'.
Since: 0.1
modifyIORef' :: HasCallStack => IORef a -> (a -> a) -> m () Source #
Lifted modifyIORef'.
Since: 0.1
atomicModifyIORef :: HasCallStack => IORef a -> (a -> (a, b)) -> m b Source #
Lifted atomicModifyIORef.
Since: 0.1
atomicModifyIORef' :: HasCallStack => IORef a -> (a -> (a, b)) -> m b Source #
Lifted atomicModifyIORef'.
Since: 0.1
Instances
Utils
atomicModifyIORef_ :: (HasCallStack, MonadIORef m) => IORef a -> (a -> a) -> m () Source #
Atomically apply a function to the contents of an IORef and return the
old and new values.
Since: 0.1
atomicModifyIORef'_ :: (HasCallStack, MonadIORef m) => IORef a -> (a -> a) -> m () Source #
Atomically apply a function to the contents of an IORef and return the
old and new values. The result of the function is forced.
Since: 0.1
Reexports
A mutable variable in the IO monad.
>>>import GHC.Internal.Data.IORef>>>r <- newIORef 0>>>readIORef r0>>>writeIORef r 1>>>readIORef r1>>>atomicWriteIORef r 2>>>readIORef r2>>>modifyIORef' r (+ 1)>>>readIORef r3>>>atomicModifyIORef' r (\a -> (a + 1, ()))>>>readIORef r4