io-classes-1.4.0.0: Type classes for concurrency with STM, ST and timing
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Concurrent.Class.MonadSTM.TVar

Description

This module corresponds to TVar in "stm" package

Synopsis

MonadSTM

type family TVar m :: Type -> Type Source #

A type of a TVar.

See TVar.

Instances

Instances details
type TVar IO Source # 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

type TVar IO = TVar
type TVar (ReaderT r m) Source # 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

type TVar (ReaderT r m) = TVar m

newTVar :: MonadSTM m => a -> STM m (TVar m a) Source #

newTVarIO :: MonadSTM m => a -> m (TVar m a) Source #

readTVar :: MonadSTM m => TVar m a -> STM m a Source #

readTVarIO :: MonadSTM m => TVar m a -> m a Source #

writeTVar :: MonadSTM m => TVar m a -> a -> STM m () Source #

modifyTVar :: MonadSTM m => TVar m a -> (a -> a) -> STM m () Source #

modifyTVar' :: MonadSTM m => TVar m a -> (a -> a) -> STM m () Source #

stateTVar :: MonadSTM m => TVar m s -> (s -> (a, s)) -> STM m a Source #

@since io-classes-0.2.0.0

swapTVar :: MonadSTM m => TVar m a -> a -> STM m a Source #

check :: MonadSTM m => Bool -> STM m () Source #

See check.

MonadLabelSTM

labelTVar :: MonadLabelledSTM m => TVar m a -> String -> STM m () Source #

Name a TVar.

MonadTraceSTM

traceTVar Source #

Arguments

:: MonadTraceSTM m 
=> proxy m 
-> TVar m a 
-> (Maybe a -> a -> InspectMonad m TraceValue)

callback which receives initial value or Nothing (if it is a newly created TVar), and the committed value.

-> STM m () 

Construct a trace output out of previous & new value of a TVar. The callback is called whenever an stm transaction which modifies the TVar is committed.

This is supported by IOSim (and IOSimPOR); IO has a trivial instance.

The simplest example is:

traceTVar (Proxy @m) tvar (\_ -> TraceString . show)

Note that the interpretation of TraceValue depends on the monad m itself (see TraceValue).

traceTVarIO :: MonadTraceSTM m => TVar m a -> (Maybe a -> a -> InspectMonad m TraceValue) -> m () Source #