ouroboros-consensus-0.21.0.0: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ouroboros.Consensus.Util.NormalForm.StrictTVar

Description

StrictTVars 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

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

uncheckedNewTVarMMonadSTM m ⇒ a → m (StrictTVar m a) Source #

Like newTVarIO, but without a NoThunks invariant.

Re-exports

type LazyTVar (m ∷ TypeType) = LazyTVar m Source #

readTVarIOMonadSTM m ⇒ StrictTVar m a → m a Source #

readTVar ∷ ∀ (m ∷ TypeType) a. MonadSTM m ⇒ StrictTVar m a → STM m a Source #

writeTVar ∷ ∀ (m ∷ TypeType) a. (MonadSTM m, HasCallStack) ⇒ StrictTVar m a → a → STM m () Source #

traceTVar ∷ ∀ (m ∷ TypeType) proxy a. MonadTraceSTM m ⇒ proxy m → StrictTVar m a → (Maybe a → a → InspectMonad m TraceValue) → STM m () Source #

traceTVarIOMonadTraceSTM m ⇒ StrictTVar m a → (Maybe a → a → InspectMonad m TraceValue) → m () Source #

labelTVar ∷ ∀ (m ∷ TypeType) a. MonadLabelledSTM m ⇒ StrictTVar m a → StringSTM m () Source #

modifyTVar ∷ ∀ (m ∷ TypeType) a. MonadSTM m ⇒ StrictTVar m a → (a → a) → STM m () Source #

stateTVar ∷ ∀ (m ∷ TypeType) s a. MonadSTM m ⇒ StrictTVar m s → (s → (a, s)) → STM m a Source #

swapTVar ∷ ∀ (m ∷ TypeType) a. MonadSTM m ⇒ StrictTVar m a → a → STM m a Source #

castStrictTVar ∷ ∀ (m ∷ TypeType) (n ∷ TypeType) a. LazyTVar m ~ LazyTVar n ⇒ StrictTVar m a → StrictTVar n a Source #

toLazyTVar ∷ ∀ (m ∷ TypeType) 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 ∷ TypeType) 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 ∷ TypeType) 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.

Orphan instances