Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module corresponds to TVar
in "stm" package
Synopsis
- data StrictTVar m a
- type LazyTVar m = TVar m
- toLazyTVar :: StrictTVar m a -> LazyTVar m a
- fromLazyTVar :: LazyTVar m a -> StrictTVar m a
- castStrictTVar :: LazyTVar m ~ LazyTVar n => StrictTVar m a -> StrictTVar n a
- newTVar :: MonadSTM m => a -> STM m (StrictTVar m a)
- newTVarIO :: MonadSTM m => a -> m (StrictTVar m a)
- newTVarWithInvariant :: (MonadSTM m, HasCallStack) => (a -> Maybe String) -> a -> STM m (StrictTVar m a)
- newTVarWithInvariantIO :: (MonadSTM m, HasCallStack) => (a -> Maybe String) -> a -> m (StrictTVar m a)
- readTVar :: MonadSTM m => StrictTVar m a -> STM m a
- readTVarIO :: MonadSTM m => StrictTVar m a -> m a
- writeTVar :: (MonadSTM m, HasCallStack) => StrictTVar m a -> a -> STM m ()
- modifyTVar :: MonadSTM m => StrictTVar m a -> (a -> a) -> STM m ()
- stateTVar :: MonadSTM m => StrictTVar m s -> (s -> (a, s)) -> STM m a
- swapTVar :: MonadSTM m => StrictTVar m a -> a -> STM m a
- check :: MonadSTM m => Bool -> STM m ()
- checkInvariant :: HasCallStack => Maybe String -> a -> a
- labelTVar :: MonadLabelledSTM m => StrictTVar m a -> String -> STM m ()
- labelTVarIO :: MonadLabelledSTM m => StrictTVar m a -> String -> m ()
- traceTVar :: MonadTraceSTM m => proxy m -> StrictTVar m a -> (Maybe a -> a -> InspectMonad m TraceValue) -> STM m ()
- traceTVarIO :: MonadTraceSTM m => StrictTVar m a -> (Maybe a -> a -> InspectMonad m TraceValue) -> m ()
StrictTVar
data StrictTVar m a Source #
toLazyTVar :: StrictTVar m a -> LazyTVar m a Source #
Get the underlying TVar
Since we obviously cannot guarantee that updates to this LazyTVar
will be
strict, this should be used with caution.
fromLazyTVar :: LazyTVar m a -> StrictTVar m a Source #
castStrictTVar :: LazyTVar m ~ LazyTVar n => StrictTVar m a -> StrictTVar n a Source #
newTVarIO :: MonadSTM m => a -> m (StrictTVar m a) Source #
:: (MonadSTM m, HasCallStack) | |
=> (a -> Maybe String) | Invariant (expect |
-> a | |
-> STM m (StrictTVar m a) |
newTVarWithInvariantIO Source #
:: (MonadSTM m, HasCallStack) | |
=> (a -> Maybe String) | Invariant (expect |
-> a | |
-> m (StrictTVar m a) |
readTVarIO :: MonadSTM m => StrictTVar m a -> m a Source #
writeTVar :: (MonadSTM m, HasCallStack) => StrictTVar m a -> a -> STM m () Source #
modifyTVar :: MonadSTM m => StrictTVar m a -> (a -> a) -> STM m () Source #
Low-level API
checkInvariant :: HasCallStack => Maybe String -> a -> a Source #
Check invariant (if enabled) before continuing
checkInvariant mErr x
is equal to x
if mErr == Nothing
, and throws
an error err
if mErr == Just err
.
This is exported so that other code that wants to conditionally check invariants can reuse the same logic, rather than having to introduce new per-package flags.
MonadLabelSTM
labelTVar :: MonadLabelledSTM m => StrictTVar m a -> String -> STM m () Source #
labelTVarIO :: MonadLabelledSTM m => StrictTVar m a -> String -> m () Source #
MonadTraceSTM
traceTVar :: MonadTraceSTM m => proxy m -> StrictTVar m a -> (Maybe a -> a -> InspectMonad m TraceValue) -> STM m () Source #
traceTVarIO :: MonadTraceSTM m => StrictTVar m a -> (Maybe a -> a -> InspectMonad m TraceValue) -> m () Source #