hw-polysemy-0.2.5.0: Opinionated polysemy library
Safe HaskellSafe-Inferred
LanguageGHC2021

HaskellWorks.Polysemy.Control.Concurrent.STM.TVar

Synopsis

Documentation

data TVar a #

Shared memory locations that support atomic memory transactions.

Instances

Instances details
Eq (TVar a)

Since: base-4.8.0.0

Instance details

Defined in GHC.Conc.Sync

Methods

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

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

newTVar :: a -> STM (TVar a) #

Create a new TVar holding a value supplied

newTVarIO :: Member (Embed IO) r => a -> Sem r (TVar a) Source #

readTVar :: TVar a -> STM a #

Return the current value stored in a TVar.

readTVarIO :: Member (Embed IO) r => TVar a -> Sem r a Source #

writeTVar :: TVar a -> a -> STM () #

Write the supplied value into a TVar.

modifyTVar :: TVar a -> (a -> a) -> STM () #

Mutate the contents of a TVar. N.B., this version is non-strict.

Since: stm-2.3

modifyTVar' :: TVar a -> (a -> a) -> STM () #

Strict version of modifyTVar.

Since: stm-2.3

stateTVar :: TVar s -> (s -> (a, s)) -> STM a #

Like modifyTVar' but the function is a simple state transition that can return a side value which is passed on as the result of the STM.

Since: stm-2.5.0

swapTVar :: TVar a -> a -> STM a #

Swap the contents of a TVar for a new value.

Since: stm-2.3