ioref-effectful-0.1: IORef effects
Safe HaskellNone
LanguageGHC2021

Effectful.IORef.Static

Description

Provides a static effect for IORef.

Since: 0.1

Synopsis

Effect

data IORefE (a :: Type -> Type) b Source #

Static effect for IORef.

Since: 0.1

Instances

Instances details
type DispatchOf IORefE Source # 
Instance details

Defined in Effectful.IORef.Static

data StaticRep IORefE Source # 
Instance details

Defined in Effectful.IORef.Static

newIORef :: forall (es :: [Effect]) a. IORefE :> es => a -> Eff es (IORef a) Source #

Lifted newIORef.

Since: 0.1

newIORef' :: forall (es :: [Effect]) a. IORefE :> es => a -> Eff es (IORef a) Source #

Evaluates a to WHNF then calls newIORef.

Since: 0.1

readIORef :: forall (es :: [Effect]) a. IORefE :> es => IORef a -> Eff es a Source #

Lifted readIORef.

Since: 0.1

writeIORef :: forall (es :: [Effect]) a. IORefE :> es => IORef a -> a -> Eff es () Source #

Lifted writeIORef.

Since: 0.1

writeIORef' :: forall (es :: [Effect]) a. IORefE :> es => IORef a -> a -> Eff es () Source #

Evaluates a to WHNF before calling writeIORef.

Since: 0.1

modifyIORef' :: forall (es :: [Effect]) a. IORefE :> es => IORef a -> (a -> a) -> Eff es () Source #

Lifted modifyIORef'.

Since: 0.1

atomicModifyIORef' :: forall (es :: [Effect]) a b. IORefE :> es => IORef a -> (a -> (a, b)) -> Eff es b Source #

Lifted atomicModifyIORef'.

Since: 0.1

Handlers

runIORef :: forall (es :: [Effect]) a. IOE :> es => Eff (IORefE ': es) a -> Eff es a Source #

Runs an IORefE effect.

Since: 0.1

Utils

atomicModifyIORef'_ :: forall (es :: [Effect]) a. IORefE :> es => IORef a -> (a -> a) -> Eff es () Source #

Variant of atomicModifyIORef' which ignores the return value.

Since: 0.1

Re-exports

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 #