HORIZON HASKELLDocslts/ghc-10.0.xa8896112026-10-18Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · a889611 · 2026-10-18

Moduleconcurrency-1.11.0.3Haskell2010

Control.Concurrent.Classy.STM.TVar

Transactional variables, for use with MonadSTM.

Deviations: There is no Eq instance for MonadSTM the TVar type. Furthermore, the newTVarIO and mkWeakTVar functions are not provided.

  • 5 values

TVars

11 declarations
familytype family TVar (stm :: Type -> Type) :: Type -> Type
#

The mutable reference type. These behave like TVars, in that they always contain a value and updates are non-blocking and synchronised.

Instances10TVar, …
  • type TVar STM = TVarDefined in concurrency-1.11.0.3 · Control.Monad.STM.Class
  • type TVar (IsSTM m) = TVar mDefined in concurrency-1.11.0.3 · Control.Monad.STM.Class
  • type TVar (IdentityT stm) = TVar stmDefined in concurrency-1.11.0.3 · Control.Monad.STM.Class
  • type TVar (RWST r w s stm) = TVar stmDefined in concurrency-1.11.0.3 · Control.Monad.STM.Class
  • type TVar (RWST r w s stm) = TVar stmDefined in concurrency-1.11.0.3 · Control.Monad.STM.Class
  • type TVar (ReaderT r stm) = TVar stmDefined in concurrency-1.11.0.3 · Control.Monad.STM.Class
  • type TVar (StateT s stm) = TVar stmDefined in concurrency-1.11.0.3 · Control.Monad.STM.Class
  • type TVar (StateT s stm) = TVar stmDefined in concurrency-1.11.0.3 · Control.Monad.STM.Class
  • type TVar (WriterT w stm) = TVar stmDefined in concurrency-1.11.0.3 · Control.Monad.STM.Class
  • type TVar (WriterT w stm) = TVar stmDefined in concurrency-1.11.0.3 · Control.Monad.STM.Class
methodnewTVar :: a -> stm (TVar stm a)
#

Create a new TVar containing the given value.

newTVar = newTVarN ""
methodnewTVarN :: String -> a -> stm (TVar stm a)
#

Create a new TVar containing the given value, but it is given a name which may be used to present more useful debugging information.

If an empty name is given, a counter starting from 0 is used. If names conflict, successive TVars with the same name are given a numeric suffix, counting up from 1.

newTVarN _ = newTVar
methodreadTVar :: TVar stm a -> stm a
#

Return the current value stored in a TVar.

methodreadTVarConc :: TVar (STM m) a -> m a
#

Read the current value stored in a TVar. This may be implemented differently for speed.

readTVarConc = atomically . readTVar
methodwriteTVar :: TVar stm a -> a -> stm ()
#

Write the supplied value into the TVar.

valuestateTVar :: MonadSTM stm => TVar stm 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.