HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Moduleouroboros-consensus-4.2.1.0

Ouroboros.Consensus.Util.NormalForm.StrictMVar

  • 2 types
  • 1 class
  • 26 values
valuecheckInvariant :: HasCallStack => Maybe String -> a -> a
#

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.

valuetoLazyMVar :: StrictMVar m a -> LazyMVar m a
#

Get the underlying MVar

Since we obviously can not guarantee that updates to this LazyMVar will be strict, this should be used with caution.

Similarly, we can not guarantee that updates to this LazyMVar do not break the original invariant that the StrictMVar held.

valueunsafeToUncheckedStrictMVar :: StrictMVar m a -> StrictMVar m a
#

Create an unchecked reference to the given checked StrictMVar.

Note that the invariant is only guaranteed when modifying the checked MVar. Any modification to the unchecked reference might break the invariants.

newtypenewtype StrictMVar (m :: Type -> Type) a
#

A strict MVar with invariant checking.

There is a weaker invariant for a StrictMVar than for a StrictTVar: although all functions that modify the StrictMVar check the invariant, we do not guarantee that the value inside the StrictMVar always satisfies the invariant. Instead, we do guarantee that if the StrictMVar is updated with a value that does not satisfy the invariant, an exception is thrown. The reason for this weaker guarantee is that leaving an MVar empty can lead to very hard to debug "blocked indefinitely" problems.

Instances1NoThunks
  • NoThunks (StrictMVar IO a) => NoThunks (StrictMVar IO a)Defined in ouroboros-consensus-4.2.1.0 · Ouroboros.Consensus.Util.NormalForm.StrictMVar · orphan

Orphan instances

1 instance