HORIZON HASKELLDocslts/ghc-10.0.x2b276322026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 2b27632 · 2026-10-31

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.

Contents
  1. TVars
Synopsis

TVars

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
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
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.