Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
StrictTVar
s with NoThunks
invariants.
Custom invariants can still be specified in addition to the default
NoThunks
invariant. See newTVarWithInvariant
and
newTVarWithInvariantIO
.
Use the checktvarinvariants
cabal flag from the strict-checked-vars
package to enable or disable invariant checks at compile time.
The exports of this module (should) mirror the exports of the
Control.Concurrent.Class.MonadSTM.Strict.TVar.Checked module from the
strict-checked-vars
package.
Synopsis
- newTVar ∷ (HasCallStack, MonadSTM m, NoThunks a) ⇒ a → STM m (StrictTVar m a)
- newTVarIO ∷ (HasCallStack, MonadSTM m, NoThunks a) ⇒ a → m (StrictTVar m a)
- newTVarWithInvariant ∷ (HasCallStack, MonadSTM m, NoThunks a) ⇒ (a → Maybe String) → a → STM m (StrictTVar m a)
- newTVarWithInvariantIO ∷ (HasCallStack, MonadSTM m, NoThunks a) ⇒ (a → Maybe String) → a → m (StrictTVar m a)
- noThunksInvariant ∷ NoThunks a ⇒ a → Maybe String
- uncheckedNewTVarM ∷ MonadSTM m ⇒ a → m (StrictTVar m a)
- data StrictTVar (m ∷ Type → Type) a
- type LazyTVar (m ∷ Type → Type) = LazyTVar m
- readTVarIO ∷ MonadSTM m ⇒ StrictTVar m a → m a
- readTVar ∷ ∀ (m ∷ Type → Type) a. MonadSTM m ⇒ StrictTVar m a → STM m a
- writeTVar ∷ ∀ (m ∷ Type → Type) a. (MonadSTM m, HasCallStack) ⇒ StrictTVar m a → a → STM m ()
- traceTVar ∷ ∀ (m ∷ Type → Type) proxy a. 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 ()
- labelTVar ∷ ∀ (m ∷ Type → Type) a. MonadLabelledSTM m ⇒ StrictTVar m a → String → STM m ()
- labelTVarIO ∷ MonadLabelledSTM m ⇒ StrictTVar m a → String → m ()
- modifyTVar ∷ ∀ (m ∷ Type → Type) a. MonadSTM m ⇒ StrictTVar m a → (a → a) → STM m ()
- stateTVar ∷ ∀ (m ∷ Type → Type) s a. MonadSTM m ⇒ StrictTVar m s → (s → (a, s)) → STM m a
- swapTVar ∷ ∀ (m ∷ Type → Type) a. MonadSTM m ⇒ StrictTVar m a → a → STM m a
- castStrictTVar ∷ ∀ (m ∷ Type → Type) (n ∷ Type → Type) a. LazyTVar m ~ LazyTVar n ⇒ StrictTVar m a → StrictTVar n a
- toLazyTVar ∷ ∀ (m ∷ Type → Type) a. StrictTVar m a → LazyTVar m a
- fromLazyTVar ∷ ∀ (m ∷ Type → Type) a. LazyTVar m a → StrictTVar m a
- unsafeToUncheckedStrictTVar ∷ ∀ (m ∷ Type → Type) a. StrictTVar m a → StrictTVar m a
StrictTVar
newTVar ∷ (HasCallStack, MonadSTM m, NoThunks a) ⇒ a → STM m (StrictTVar m a) Source #
Create a StrictTVar
with a NoThunks
invariant.
newTVarIO ∷ (HasCallStack, MonadSTM m, NoThunks a) ⇒ a → m (StrictTVar m a) Source #
Create an StrictTVar
with a NoThunks
invariant.
newTVarWithInvariant ∷ (HasCallStack, MonadSTM m, NoThunks a) ⇒ (a → Maybe String) → a → STM m (StrictTVar m a) Source #
Create a StrictTVar
with a custom invariant and a NoThunks
invariant.
When both the custom and NoThunks
invariants are broken, only the error
related to the custom invariant is reported.
newTVarWithInvariantIO ∷ (HasCallStack, MonadSTM m, NoThunks a) ⇒ (a → Maybe String) → a → m (StrictTVar m a) Source #
Create a StrictTVar
with a custom invariant and a NoThunks
invariant.
When both the custom and NoThunks
invariants are broken, only the error
related to the custom invariant is reported.
Invariant
Unchecked
uncheckedNewTVarM ∷ MonadSTM m ⇒ a → m (StrictTVar m a) Source #
Re-exports
data StrictTVar (m ∷ Type → Type) a Source #
Instances
NoThunks (StrictTVar IO a) ⇒ NoThunks (StrictTVar IO a) Source # | |
readTVarIO ∷ MonadSTM m ⇒ StrictTVar m a → m a Source #
writeTVar ∷ ∀ (m ∷ Type → Type) a. (MonadSTM m, HasCallStack) ⇒ StrictTVar m a → a → STM m () Source #
traceTVar ∷ ∀ (m ∷ Type → Type) proxy a. 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 #
labelTVar ∷ ∀ (m ∷ Type → Type) a. MonadLabelledSTM m ⇒ StrictTVar m a → String → STM m () Source #
labelTVarIO ∷ MonadLabelledSTM m ⇒ StrictTVar m a → String → m () Source #
modifyTVar ∷ ∀ (m ∷ Type → Type) a. MonadSTM m ⇒ StrictTVar m a → (a → a) → STM m () Source #
castStrictTVar ∷ ∀ (m ∷ Type → Type) (n ∷ Type → Type) a. LazyTVar m ~ LazyTVar n ⇒ StrictTVar m a → StrictTVar n a Source #
toLazyTVar ∷ ∀ (m ∷ Type → Type) a. 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.
Similarly, we can not guarantee that updates to this LazyTVar
do not break
the original invariant that the StrictTVar
held.
fromLazyTVar ∷ ∀ (m ∷ Type → Type) a. LazyTVar m a → StrictTVar m a Source #
Create a StrictMVar
from a LazyMVar
It is not guaranteed that the LazyTVar
contains a value that is in WHNF, so
there is no guarantee that the resulting StrictTVar
contains a value that
is in WHNF. This should be used with caution.
The resulting StrictTVar
has a trivial invariant.
unsafeToUncheckedStrictTVar ∷ ∀ (m ∷ Type → Type) a. StrictTVar m a → StrictTVar m a Source #
Create an unchecked reference to the given checked StrictTVar
.
Note that the invariant is only guaranteed when modifying the checked TVar. Any modification to the unchecked reference might break the invariants.