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

Ouroboros.Consensus.Util.MonadSTM.NormalForm

Contents

Synopsis

Documentation

data StrictSVar m a Source #

Strict SVar (modelled using a lazy TMVar under the hood)

The StrictSVar API is slightly stronger than the usual SVar one, as we offer a primitive to read the value of the SVar even if it is empty (in which case we will return the oldest known stale one). See readSVarSTM.

There is a weaker invariant for a StrictSVar than for a StrictTVar: although all functions that modify the StrictSVar check the invariant, we do not guarantee that the value inside the StrictSVar always satisfies the invariant. Instead, we do guarantee that if the StrictSVar 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 SVar empty can lead to very hard to debug "blocked indefinitely" problems.

This is also the reason we do not offer support for an invariant in StrictTMVar: if we throw an exception from an STM transaction, the STM transaction is not executed, and so we would not even be able to provide the weaker guarantee that we provide for StrictSVar.

Constructors

StrictSVar 

Fields

  • invariant ∷ !(a → Maybe String)

    Invariant checked whenever updating the StrictSVar.

  • tmvar ∷ !(TMVar m a)

    The main TMVar supporting this StrictSVar

  • tvar ∷ !(TVar m a)

    TVar for supporting readSVarSTM

    This TVar is always kept up to date with the TMVar, but holds on the old value of the TMVar when it is empty. This is very useful to support single writer/many reader scenarios.

    NOTE: We should always update the tmvar before the tvar so that if the update to the tmvar fails, the 'tvar is left unchanged.

castStrictSVar ∷ (TMVar m ~ TMVar n, TVar m ~ TVar n) ⇒ StrictSVar m a → StrictSVar n a Source #

modifySVar ∷ (MonadSTM m, MonadCatch m, HasCallStack) ⇒ StrictSVar m a → (a → m (a, b)) → m b Source #

modifySVar_ ∷ (MonadSTM m, MonadCatch m, HasCallStack) ⇒ StrictSVar m a → (a → m a) → m () Source #

putSVar ∷ (MonadSTM m, HasCallStack) ⇒ StrictSVar m a → a → m () Source #

readSVarMonadSTM m ⇒ StrictSVar m a → m a Source #

readSVarSTMMonadSTM m ⇒ StrictSVar m a → STM m a Source #

Read the possibly-stale value of the SVar

Will return the current value of the SVar if it non-empty, or the last known value otherwise.

swapSVar ∷ (MonadSTM m, HasCallStack) ⇒ StrictSVar m a → a → m a Source #

Swap value of a StrictSVar

NOTE: Since swapping the value can't leave the StrictSVar empty, we could check the invariant first and only then swap. We nonetheless swap first and check the invariant after to keep the semantics the same with putSVar, otherwise it will be difficult to understand when a StrictSVar is updated and when it is not.

takeSVarMonadSTM m ⇒ StrictSVar m a → m a Source #

tryPutSVar ∷ (MonadSTM m, HasCallStack) ⇒ StrictSVar m a → a → m Bool Source #

tryReadSVarMonadSTM m ⇒ StrictSVar m a → m (Maybe a) Source #

tryTakeSVarMonadSTM m ⇒ StrictSVar m a → m (Maybe a) Source #

updateSVar ∷ (MonadSTM m, HasCallStack) ⇒ StrictSVar m a → (a → (a, b)) → m b Source #

updateSVar_ ∷ (MonadSTM m, HasCallStack) ⇒ StrictSVar m a → (a → a) → m () Source #

class (Monad m, Monad (STM m)) ⇒ MonadSTM (m ∷ TypeType) where Source #

The STM primitives parametrised by a monad m.

Associated Types

type STM (m ∷ TypeType) = (stm ∷ TypeType) | stm → m Source #

The STM monad.

Methods

atomicallyHasCallStackSTM m a → m a Source #

Atomically run an STM computation.

See atomically.

retrySTM m a Source #

See retry.

orElseSTM m a → STM m a → STM m a Source #

See orElse.

checkBoolSTM m () Source #

See check.

Instances

Instances details
MonadSTM IO 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

Associated Types

type STM IO = (stm ∷ TypeType) Source #

type TVar IOTypeType Source #

type TMVar IOTypeType Source #

type TQueue IOTypeType Source #

type TBQueue IOTypeType Source #

type TArray IOTypeTypeType Source #

type TSem IO Source #

type TChan IOTypeType Source #

Methods

atomicallyHasCallStackSTM IO a → IO a Source #

newTVar ∷ a → STM IO (TVar IO a) Source #

readTVarTVar IO a → STM IO a Source #

writeTVarTVar IO a → a → STM IO () Source #

retrySTM IO a Source #

orElseSTM IO a → STM IO a → STM IO a Source #

modifyTVarTVar IO a → (a → a) → STM IO () Source #

modifyTVar'TVar IO a → (a → a) → STM IO () Source #

stateTVarTVar IO s → (s → (a, s)) → STM IO a Source #

swapTVarTVar IO a → a → STM IO a Source #

checkBoolSTM IO () Source #

newTMVar ∷ a → STM IO (TMVar IO a) Source #

newEmptyTMVarSTM IO (TMVar IO a) Source #

takeTMVarTMVar IO a → STM IO a Source #

tryTakeTMVarTMVar IO a → STM IO (Maybe a) Source #

putTMVarTMVar IO a → a → STM IO () Source #

tryPutTMVarTMVar IO a → a → STM IO Bool Source #

readTMVarTMVar IO a → STM IO a Source #

tryReadTMVarTMVar IO a → STM IO (Maybe a) Source #

swapTMVarTMVar IO a → a → STM IO a Source #

writeTMVarTMVar IO a → a → STM IO () Source #

isEmptyTMVarTMVar IO a → STM IO Bool Source #

newTQueueSTM IO (TQueue IO a) Source #

readTQueueTQueue IO a → STM IO a Source #

tryReadTQueueTQueue IO a → STM IO (Maybe a) Source #

peekTQueueTQueue IO a → STM IO a Source #

tryPeekTQueueTQueue IO a → STM IO (Maybe a) Source #

flushTQueueTQueue IO a → STM IO [a] Source #

writeTQueueTQueue IO a → a → STM IO () Source #

isEmptyTQueueTQueue IO a → STM IO Bool Source #

unGetTQueueTQueue IO a → a → STM IO () Source #

newTBQueueNaturalSTM IO (TBQueue IO a) Source #

readTBQueueTBQueue IO a → STM IO a Source #

tryReadTBQueueTBQueue IO a → STM IO (Maybe a) Source #

peekTBQueueTBQueue IO a → STM IO a Source #

tryPeekTBQueueTBQueue IO a → STM IO (Maybe a) Source #

flushTBQueueTBQueue IO a → STM IO [a] Source #

writeTBQueueTBQueue IO a → a → STM IO () Source #

lengthTBQueueTBQueue IO a → STM IO Natural Source #

isEmptyTBQueueTBQueue IO a → STM IO Bool Source #

isFullTBQueueTBQueue IO a → STM IO Bool Source #

unGetTBQueueTBQueue IO a → a → STM IO () Source #

newTSemIntegerSTM IO (TSem IO) Source #

waitTSemTSem IOSTM IO () Source #

signalTSemTSem IOSTM IO () Source #

signalTSemNNaturalTSem IOSTM IO () Source #

newTChanSTM IO (TChan IO a) Source #

newBroadcastTChanSTM IO (TChan IO a) Source #

dupTChanTChan IO a → STM IO (TChan IO a) Source #

cloneTChanTChan IO a → STM IO (TChan IO a) Source #

readTChanTChan IO a → STM IO a Source #

tryReadTChanTChan IO a → STM IO (Maybe a) Source #

peekTChanTChan IO a → STM IO a Source #

tryPeekTChanTChan IO a → STM IO (Maybe a) Source #

writeTChanTChan IO a → a → STM IO () Source #

unGetTChanTChan IO a → a → STM IO () Source #

isEmptyTChanTChan IO a → STM IO Bool Source #

newTVarIO ∷ a → IO (TVar IO a) Source #

readTVarIOTVar IO a → IO a Source #

newTMVarIO ∷ a → IO (TMVar IO a) Source #

newEmptyTMVarIOIO (TMVar IO a) Source #

newTQueueIOIO (TQueue IO a) Source #

newTBQueueIONaturalIO (TBQueue IO a) Source #

newTChanIOIO (TChan IO a) Source #

newBroadcastTChanIOIO (TChan IO a) Source #

MonadSTM m ⇒ MonadSTM (WithEarlyExit m) Source # 
Instance details

Defined in Ouroboros.Consensus.Util.EarlyExit

Associated Types

type STM (WithEarlyExit m) = (stm ∷ TypeType) Source #

type TVar (WithEarlyExit m) ∷ TypeType Source #

type TMVar (WithEarlyExit m) ∷ TypeType Source #

type TQueue (WithEarlyExit m) ∷ TypeType Source #

type TBQueue (WithEarlyExit m) ∷ TypeType Source #

type TArray (WithEarlyExit m) ∷ TypeTypeType Source #

type TSem (WithEarlyExit m) Source #

type TChan (WithEarlyExit m) ∷ TypeType Source #

Methods

atomicallyHasCallStackSTM (WithEarlyExit m) a → WithEarlyExit m a Source #

newTVar ∷ a → STM (WithEarlyExit m) (TVar (WithEarlyExit m) a) Source #

readTVarTVar (WithEarlyExit m) a → STM (WithEarlyExit m) a Source #

writeTVarTVar (WithEarlyExit m) a → a → STM (WithEarlyExit m) () Source #

retrySTM (WithEarlyExit m) a Source #

orElseSTM (WithEarlyExit m) a → STM (WithEarlyExit m) a → STM (WithEarlyExit m) a Source #

modifyTVarTVar (WithEarlyExit m) a → (a → a) → STM (WithEarlyExit m) () Source #

modifyTVar'TVar (WithEarlyExit m) a → (a → a) → STM (WithEarlyExit m) () Source #

stateTVarTVar (WithEarlyExit m) s → (s → (a, s)) → STM (WithEarlyExit m) a Source #

swapTVarTVar (WithEarlyExit m) a → a → STM (WithEarlyExit m) a Source #

checkBoolSTM (WithEarlyExit m) () Source #

newTMVar ∷ a → STM (WithEarlyExit m) (TMVar (WithEarlyExit m) a) Source #

newEmptyTMVarSTM (WithEarlyExit m) (TMVar (WithEarlyExit m) a) Source #

takeTMVarTMVar (WithEarlyExit m) a → STM (WithEarlyExit m) a Source #

tryTakeTMVarTMVar (WithEarlyExit m) a → STM (WithEarlyExit m) (Maybe a) Source #

putTMVarTMVar (WithEarlyExit m) a → a → STM (WithEarlyExit m) () Source #

tryPutTMVarTMVar (WithEarlyExit m) a → a → STM (WithEarlyExit m) Bool Source #

readTMVarTMVar (WithEarlyExit m) a → STM (WithEarlyExit m) a Source #

tryReadTMVarTMVar (WithEarlyExit m) a → STM (WithEarlyExit m) (Maybe a) Source #

swapTMVarTMVar (WithEarlyExit m) a → a → STM (WithEarlyExit m) a Source #

writeTMVarTMVar (WithEarlyExit m) a → a → STM (WithEarlyExit m) () Source #

isEmptyTMVarTMVar (WithEarlyExit m) a → STM (WithEarlyExit m) Bool Source #

newTQueueSTM (WithEarlyExit m) (TQueue (WithEarlyExit m) a) Source #

readTQueueTQueue (WithEarlyExit m) a → STM (WithEarlyExit m) a Source #

tryReadTQueueTQueue (WithEarlyExit m) a → STM (WithEarlyExit m) (Maybe a) Source #

peekTQueueTQueue (WithEarlyExit m) a → STM (WithEarlyExit m) a Source #

tryPeekTQueueTQueue (WithEarlyExit m) a → STM (WithEarlyExit m) (Maybe a) Source #

flushTQueueTQueue (WithEarlyExit m) a → STM (WithEarlyExit m) [a] Source #

writeTQueueTQueue (WithEarlyExit m) a → a → STM (WithEarlyExit m) () Source #

isEmptyTQueueTQueue (WithEarlyExit m) a → STM (WithEarlyExit m) Bool Source #

unGetTQueueTQueue (WithEarlyExit m) a → a → STM (WithEarlyExit m) () Source #

newTBQueueNaturalSTM (WithEarlyExit m) (TBQueue (WithEarlyExit m) a) Source #

readTBQueueTBQueue (WithEarlyExit m) a → STM (WithEarlyExit m) a Source #

tryReadTBQueueTBQueue (WithEarlyExit m) a → STM (WithEarlyExit m) (Maybe a) Source #

peekTBQueueTBQueue (WithEarlyExit m) a → STM (WithEarlyExit m) a Source #

tryPeekTBQueueTBQueue (WithEarlyExit m) a → STM (WithEarlyExit m) (Maybe a) Source #

flushTBQueueTBQueue (WithEarlyExit m) a → STM (WithEarlyExit m) [a] Source #

writeTBQueueTBQueue (WithEarlyExit m) a → a → STM (WithEarlyExit m) () Source #

lengthTBQueueTBQueue (WithEarlyExit m) a → STM (WithEarlyExit m) Natural Source #

isEmptyTBQueueTBQueue (WithEarlyExit m) a → STM (WithEarlyExit m) Bool Source #

isFullTBQueueTBQueue (WithEarlyExit m) a → STM (WithEarlyExit m) Bool Source #

unGetTBQueueTBQueue (WithEarlyExit m) a → a → STM (WithEarlyExit m) () Source #

newTSemIntegerSTM (WithEarlyExit m) (TSem (WithEarlyExit m)) Source #

waitTSemTSem (WithEarlyExit m) → STM (WithEarlyExit m) () Source #

signalTSemTSem (WithEarlyExit m) → STM (WithEarlyExit m) () Source #

signalTSemNNaturalTSem (WithEarlyExit m) → STM (WithEarlyExit m) () Source #

newTChanSTM (WithEarlyExit m) (TChan (WithEarlyExit m) a) Source #

newBroadcastTChanSTM (WithEarlyExit m) (TChan (WithEarlyExit m) a) Source #

dupTChanTChan (WithEarlyExit m) a → STM (WithEarlyExit m) (TChan (WithEarlyExit m) a) Source #

cloneTChanTChan (WithEarlyExit m) a → STM (WithEarlyExit m) (TChan (WithEarlyExit m) a) Source #

readTChanTChan (WithEarlyExit m) a → STM (WithEarlyExit m) a Source #

tryReadTChanTChan (WithEarlyExit m) a → STM (WithEarlyExit m) (Maybe a) Source #

peekTChanTChan (WithEarlyExit m) a → STM (WithEarlyExit m) a Source #

tryPeekTChanTChan (WithEarlyExit m) a → STM (WithEarlyExit m) (Maybe a) Source #

writeTChanTChan (WithEarlyExit m) a → a → STM (WithEarlyExit m) () Source #

unGetTChanTChan (WithEarlyExit m) a → a → STM (WithEarlyExit m) () Source #

isEmptyTChanTChan (WithEarlyExit m) a → STM (WithEarlyExit m) Bool Source #

newTVarIO ∷ a → WithEarlyExit m (TVar (WithEarlyExit m) a) Source #

readTVarIOTVar (WithEarlyExit m) a → WithEarlyExit m a Source #

newTMVarIO ∷ a → WithEarlyExit m (TMVar (WithEarlyExit m) a) Source #

newEmptyTMVarIOWithEarlyExit m (TMVar (WithEarlyExit m) a) Source #

newTQueueIOWithEarlyExit m (TQueue (WithEarlyExit m) a) Source #

newTBQueueIONaturalWithEarlyExit m (TBQueue (WithEarlyExit m) a) Source #

newTChanIOWithEarlyExit m (TChan (WithEarlyExit m) a) Source #

newBroadcastTChanIOWithEarlyExit m (TChan (WithEarlyExit m) a) Source #

MonadSTM m ⇒ MonadSTM (ReaderT r m)

The underlying stm monad is also transformed.

Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

Associated Types

type STM (ReaderT r m) = (stm ∷ TypeType) Source #

type TVar (ReaderT r m) ∷ TypeType Source #

type TMVar (ReaderT r m) ∷ TypeType Source #

type TQueue (ReaderT r m) ∷ TypeType Source #

type TBQueue (ReaderT r m) ∷ TypeType Source #

type TArray (ReaderT r m) ∷ TypeTypeType Source #

type TSem (ReaderT r m) Source #

type TChan (ReaderT r m) ∷ TypeType Source #

Methods

atomicallyHasCallStackSTM (ReaderT r m) a → ReaderT r m a Source #

newTVar ∷ a → STM (ReaderT r m) (TVar (ReaderT r m) a) Source #

readTVarTVar (ReaderT r m) a → STM (ReaderT r m) a Source #

writeTVarTVar (ReaderT r m) a → a → STM (ReaderT r m) () Source #

retrySTM (ReaderT r m) a Source #

orElseSTM (ReaderT r m) a → STM (ReaderT r m) a → STM (ReaderT r m) a Source #

modifyTVarTVar (ReaderT r m) a → (a → a) → STM (ReaderT r m) () Source #

modifyTVar'TVar (ReaderT r m) a → (a → a) → STM (ReaderT r m) () Source #

stateTVarTVar (ReaderT r m) s → (s → (a, s)) → STM (ReaderT r m) a Source #

swapTVarTVar (ReaderT r m) a → a → STM (ReaderT r m) a Source #

checkBoolSTM (ReaderT r m) () Source #

newTMVar ∷ a → STM (ReaderT r m) (TMVar (ReaderT r m) a) Source #

newEmptyTMVarSTM (ReaderT r m) (TMVar (ReaderT r m) a) Source #

takeTMVarTMVar (ReaderT r m) a → STM (ReaderT r m) a Source #

tryTakeTMVarTMVar (ReaderT r m) a → STM (ReaderT r m) (Maybe a) Source #

putTMVarTMVar (ReaderT r m) a → a → STM (ReaderT r m) () Source #

tryPutTMVarTMVar (ReaderT r m) a → a → STM (ReaderT r m) Bool Source #

readTMVarTMVar (ReaderT r m) a → STM (ReaderT r m) a Source #

tryReadTMVarTMVar (ReaderT r m) a → STM (ReaderT r m) (Maybe a) Source #

swapTMVarTMVar (ReaderT r m) a → a → STM (ReaderT r m) a Source #

writeTMVarTMVar (ReaderT r m) a → a → STM (ReaderT r m) () Source #

isEmptyTMVarTMVar (ReaderT r m) a → STM (ReaderT r m) Bool Source #

newTQueueSTM (ReaderT r m) (TQueue (ReaderT r m) a) Source #

readTQueueTQueue (ReaderT r m) a → STM (ReaderT r m) a Source #

tryReadTQueueTQueue (ReaderT r m) a → STM (ReaderT r m) (Maybe a) Source #

peekTQueueTQueue (ReaderT r m) a → STM (ReaderT r m) a Source #

tryPeekTQueueTQueue (ReaderT r m) a → STM (ReaderT r m) (Maybe a) Source #

flushTQueueTQueue (ReaderT r m) a → STM (ReaderT r m) [a] Source #

writeTQueueTQueue (ReaderT r m) a → a → STM (ReaderT r m) () Source #

isEmptyTQueueTQueue (ReaderT r m) a → STM (ReaderT r m) Bool Source #

unGetTQueueTQueue (ReaderT r m) a → a → STM (ReaderT r m) () Source #

newTBQueueNaturalSTM (ReaderT r m) (TBQueue (ReaderT r m) a) Source #

readTBQueueTBQueue (ReaderT r m) a → STM (ReaderT r m) a Source #

tryReadTBQueueTBQueue (ReaderT r m) a → STM (ReaderT r m) (Maybe a) Source #

peekTBQueueTBQueue (ReaderT r m) a → STM (ReaderT r m) a Source #

tryPeekTBQueueTBQueue (ReaderT r m) a → STM (ReaderT r m) (Maybe a) Source #

flushTBQueueTBQueue (ReaderT r m) a → STM (ReaderT r m) [a] Source #

writeTBQueueTBQueue (ReaderT r m) a → a → STM (ReaderT r m) () Source #

lengthTBQueueTBQueue (ReaderT r m) a → STM (ReaderT r m) Natural Source #

isEmptyTBQueueTBQueue (ReaderT r m) a → STM (ReaderT r m) Bool Source #

isFullTBQueueTBQueue (ReaderT r m) a → STM (ReaderT r m) Bool Source #

unGetTBQueueTBQueue (ReaderT r m) a → a → STM (ReaderT r m) () Source #

newTSemIntegerSTM (ReaderT r m) (TSem (ReaderT r m)) Source #

waitTSemTSem (ReaderT r m) → STM (ReaderT r m) () Source #

signalTSemTSem (ReaderT r m) → STM (ReaderT r m) () Source #

signalTSemNNaturalTSem (ReaderT r m) → STM (ReaderT r m) () Source #

newTChanSTM (ReaderT r m) (TChan (ReaderT r m) a) Source #

newBroadcastTChanSTM (ReaderT r m) (TChan (ReaderT r m) a) Source #

dupTChanTChan (ReaderT r m) a → STM (ReaderT r m) (TChan (ReaderT r m) a) Source #

cloneTChanTChan (ReaderT r m) a → STM (ReaderT r m) (TChan (ReaderT r m) a) Source #

readTChanTChan (ReaderT r m) a → STM (ReaderT r m) a Source #

tryReadTChanTChan (ReaderT r m) a → STM (ReaderT r m) (Maybe a) Source #

peekTChanTChan (ReaderT r m) a → STM (ReaderT r m) a Source #

tryPeekTChanTChan (ReaderT r m) a → STM (ReaderT r m) (Maybe a) Source #

writeTChanTChan (ReaderT r m) a → a → STM (ReaderT r m) () Source #

unGetTChanTChan (ReaderT r m) a → a → STM (ReaderT r m) () Source #

isEmptyTChanTChan (ReaderT r m) a → STM (ReaderT r m) Bool Source #

newTVarIO ∷ a → ReaderT r m (TVar (ReaderT r m) a) Source #

readTVarIOTVar (ReaderT r m) a → ReaderT r m a Source #

newTMVarIO ∷ a → ReaderT r m (TMVar (ReaderT r m) a) Source #

newEmptyTMVarIOReaderT r m (TMVar (ReaderT r m) a) Source #

newTQueueIOReaderT r m (TQueue (ReaderT r m) a) Source #

newTBQueueIONaturalReaderT r m (TBQueue (ReaderT r m) a) Source #

newTChanIOReaderT r m (TChan (ReaderT r m) a) Source #

newBroadcastTChanIOReaderT r m (TChan (ReaderT r m) a) Source #

type family STM (m ∷ TypeType) = (stm ∷ TypeType) | stm → m Source #

The STM monad.

Instances

Instances details
type STM IO 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

type STM IO = STM
type STM (WithEarlyExit m) Source # 
Instance details

Defined in Ouroboros.Consensus.Util.EarlyExit

type STM (ReaderT r m) 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

type STM (ReaderT r m) = ReaderT r (STM m)

class MonadInspectSTM m ⇒ MonadTraceSTM (m ∷ TypeType) where Source #

MonadTraceSTM allows to trace values of stm variables when stm transaction is committed. This allows to verify invariants when a variable is committed.

Minimal complete definition

traceTVar, traceTQueue, traceTBQueue

Methods

traceTMVar ∷ proxy m → TMVar m a → (Maybe (Maybe a) → Maybe a → InspectMonad m TraceValue) → STM m () Source #

traceTQueue ∷ proxy m → TQueue m a → (Maybe [a] → [a] → InspectMonad m TraceValue) → STM m () Source #

traceTBQueue ∷ proxy m → TBQueue m a → (Maybe [a] → [a] → InspectMonad m TraceValue) → STM m () Source #

traceTSem ∷ proxy m → TSem m → (Maybe IntegerIntegerInspectMonad m TraceValue) → STM m () Source #

traceTMVarIOTMVar m a → (Maybe (Maybe a) → Maybe a → InspectMonad m TraceValue) → m () Source #

traceTQueueIOTQueue m a → (Maybe [a] → [a] → InspectMonad m TraceValue) → m () Source #

traceTBQueueIOTBQueue m a → (Maybe [a] → [a] → InspectMonad m TraceValue) → m () Source #

traceTSemIOTSem m → (Maybe IntegerIntegerInspectMonad m TraceValue) → m () Source #

Instances

Instances details
MonadTraceSTM IO

noop instance

Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

Methods

traceTVar ∷ proxy IOTVar IO a → (Maybe a → a → InspectMonad IO TraceValue) → STM IO () Source #

traceTMVar ∷ proxy IOTMVar IO a → (Maybe (Maybe a) → Maybe a → InspectMonad IO TraceValue) → STM IO () Source #

traceTQueue ∷ proxy IOTQueue IO a → (Maybe [a] → [a] → InspectMonad IO TraceValue) → STM IO () Source #

traceTBQueue ∷ proxy IOTBQueue IO a → (Maybe [a] → [a] → InspectMonad IO TraceValue) → STM IO () Source #

traceTSem ∷ proxy IOTSem IO → (Maybe IntegerIntegerInspectMonad IO TraceValue) → STM IO () Source #

traceTVarIOTVar IO a → (Maybe a → a → InspectMonad IO TraceValue) → IO () Source #

traceTMVarIOTMVar IO a → (Maybe (Maybe a) → Maybe a → InspectMonad IO TraceValue) → IO () Source #

traceTQueueIOTQueue IO a → (Maybe [a] → [a] → InspectMonad IO TraceValue) → IO () Source #

traceTBQueueIOTBQueue IO a → (Maybe [a] → [a] → InspectMonad IO TraceValue) → IO () Source #

traceTSemIOTSem IO → (Maybe IntegerIntegerInspectMonad IO TraceValue) → IO () Source #

MonadTraceSTM m ⇒ MonadTraceSTM (WithEarlyExit m) Source # 
Instance details

Defined in Ouroboros.Consensus.Util.EarlyExit

Methods

traceTVar ∷ proxy (WithEarlyExit m) → TVar (WithEarlyExit m) a → (Maybe a → a → InspectMonad (WithEarlyExit m) TraceValue) → STM (WithEarlyExit m) () Source #

traceTMVar ∷ proxy (WithEarlyExit m) → TMVar (WithEarlyExit m) a → (Maybe (Maybe a) → Maybe a → InspectMonad (WithEarlyExit m) TraceValue) → STM (WithEarlyExit m) () Source #

traceTQueue ∷ proxy (WithEarlyExit m) → TQueue (WithEarlyExit m) a → (Maybe [a] → [a] → InspectMonad (WithEarlyExit m) TraceValue) → STM (WithEarlyExit m) () Source #

traceTBQueue ∷ proxy (WithEarlyExit m) → TBQueue (WithEarlyExit m) a → (Maybe [a] → [a] → InspectMonad (WithEarlyExit m) TraceValue) → STM (WithEarlyExit m) () Source #

traceTSem ∷ proxy (WithEarlyExit m) → TSem (WithEarlyExit m) → (Maybe IntegerIntegerInspectMonad (WithEarlyExit m) TraceValue) → STM (WithEarlyExit m) () Source #

traceTVarIOTVar (WithEarlyExit m) a → (Maybe a → a → InspectMonad (WithEarlyExit m) TraceValue) → WithEarlyExit m () Source #

traceTMVarIOTMVar (WithEarlyExit m) a → (Maybe (Maybe a) → Maybe a → InspectMonad (WithEarlyExit m) TraceValue) → WithEarlyExit m () Source #

traceTQueueIOTQueue (WithEarlyExit m) a → (Maybe [a] → [a] → InspectMonad (WithEarlyExit m) TraceValue) → WithEarlyExit m () Source #

traceTBQueueIOTBQueue (WithEarlyExit m) a → (Maybe [a] → [a] → InspectMonad (WithEarlyExit m) TraceValue) → WithEarlyExit m () Source #

traceTSemIOTSem (WithEarlyExit m) → (Maybe IntegerIntegerInspectMonad (WithEarlyExit m) TraceValue) → WithEarlyExit m () Source #

data TraceValue where Source #

A GADT which instructs how to trace the value. The traceDynamic will use dynamic tracing, e.g. "Control.Monad.IOSim.traceM"; while traceString will be traced with EventSay. The IOSims dynamic tracing allows to recover the value from the simulation trace (see "Control.Monad.IOSim.selectTraceEventsDynamic").

Constructors

TraceValue 

Fields

Bundled Patterns

pattern DontTraceTraceValue

Do not trace the value.

pattern TraceStringStringTraceValue

Use only string tracing.

pattern TraceDynamic ∷ () ⇒ Typeable tr ⇒ tr → TraceValue

Use only a dynamic tracer.

class (MonadSTM m, Monad (InspectMonad m)) ⇒ MonadInspectSTM (m ∷ TypeType) where Source #

This type class is indented for 'io-sim', where one might want to access a TVar in the underlying ST monad.

Associated Types

type InspectMonad (m ∷ TypeType) ∷ TypeType Source #

Methods

inspectTVar ∷ proxy m → TVar m a → InspectMonad m a Source #

Return the value of a TVar as an InspectMonad computation.

inspectTVar is useful if the value of a TVar observed by traceTVar contains other TVars.

inspectTMVar ∷ proxy m → TMVar m a → InspectMonad m (Maybe a) Source #

Return the value of a MonadSTM as an InspectMonad computation.

Instances

Instances details
MonadInspectSTM IO 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

Associated Types

type InspectMonad IOTypeType Source #

Methods

inspectTVar ∷ proxy IOTVar IO a → InspectMonad IO a Source #

inspectTMVar ∷ proxy IOTMVar IO a → InspectMonad IO (Maybe a) Source #

(MonadInspectSTM m, Monad (InspectMonad m)) ⇒ MonadInspectSTM (WithEarlyExit m) Source # 
Instance details

Defined in Ouroboros.Consensus.Util.EarlyExit

Associated Types

type InspectMonad (WithEarlyExit m) ∷ TypeType Source #

type family InspectMonad (m ∷ TypeType) ∷ TypeType Source #

Instances

Instances details
type InspectMonad IO 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

type InspectMonad (WithEarlyExit m) Source # 
Instance details

Defined in Ouroboros.Consensus.Util.EarlyExit

class MonadSTM m ⇒ MonadLabelledSTM (m ∷ TypeType) Source #

Labelled TVars & friends.

The IO instances is no-op, the IOSim instance enhances simulation trace. This is very useful when analysing low lever concurrency issues (e.g. deadlocks, livelocks etc).

Minimal complete definition

labelTVar

Instances

Instances details
MonadLabelledSTM IO

noop instance

Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

Methods

labelTVarTVar IO a → StringSTM IO () Source #

labelTMVarTMVar IO a → StringSTM IO () Source #

labelTQueueTQueue IO a → StringSTM IO () Source #

labelTBQueueTBQueue IO a → StringSTM IO () Source #

labelTArray ∷ (Ix i, Show i) ⇒ TArray IO i e → StringSTM IO () Source #

labelTSemTSem IOStringSTM IO () Source #

labelTChanTChan IO a → StringSTM IO () Source #

labelTVarIOTVar IO a → StringIO () Source #

labelTMVarIOTMVar IO a → StringIO () Source #

labelTQueueIOTQueue IO a → StringIO () Source #

labelTBQueueIOTBQueue IO a → StringIO () Source #

labelTArrayIO ∷ (Ix i, Show i) ⇒ TArray IO i e → StringIO () Source #

labelTSemIOTSem IOStringIO () Source #

labelTChanIOTChan IO a → StringIO () Source #

MonadLabelledSTM m ⇒ MonadLabelledSTM (WithEarlyExit m) Source # 
Instance details

Defined in Ouroboros.Consensus.Util.EarlyExit

data StrictTMVar (m ∷ TypeType) a Source #

TMVar that keeps its value in WHNF at all times

type LazyTMVar (m ∷ TypeType) = TMVar m Source #

throwSTM ∷ ∀ (m ∷ TypeType) e a. (MonadSTM m, MonadThrow (STM m), Exception e) ⇒ e → STM m a Source #

throwIO specialised to stm monad.

labelTMVar ∷ ∀ (m ∷ TypeType) a. MonadLabelledSTM m ⇒ StrictTMVar m a → StringSTM m () Source #

newEmptyTMVar ∷ ∀ (m ∷ TypeType) a. MonadSTM m ⇒ STM m (StrictTMVar m a) Source #

takeTMVar ∷ ∀ (m ∷ TypeType) a. MonadSTM m ⇒ StrictTMVar m a → STM m a Source #

tryTakeTMVar ∷ ∀ (m ∷ TypeType) a. MonadSTM m ⇒ StrictTMVar m a → STM m (Maybe a) Source #

putTMVar ∷ ∀ (m ∷ TypeType) a. MonadSTM m ⇒ StrictTMVar m a → a → STM m () Source #

tryPutTMVar ∷ ∀ (m ∷ TypeType) a. MonadSTM m ⇒ StrictTMVar m a → a → STM m Bool Source #

readTMVar ∷ ∀ (m ∷ TypeType) a. MonadSTM m ⇒ StrictTMVar m a → STM m a Source #

tryReadTMVar ∷ ∀ (m ∷ TypeType) a. MonadSTM m ⇒ StrictTMVar m a → STM m (Maybe a) Source #

swapTMVar ∷ ∀ (m ∷ TypeType) a. MonadSTM m ⇒ StrictTMVar m a → a → STM m a Source #

writeTMVar ∷ ∀ (m ∷ TypeType) a. MonadSTM m ⇒ StrictTMVar m a → a → STM m () Source #

isEmptyTMVar ∷ ∀ (m ∷ TypeType) a. MonadSTM m ⇒ StrictTMVar m a → STM m Bool Source #

fromLazyTMVar ∷ ∀ (m ∷ TypeType) a. LazyTMVar m a → StrictTMVar m a Source #

castStrictTMVar ∷ ∀ (m ∷ TypeType) (n ∷ TypeType) a. LazyTMVar m ~ LazyTMVar n ⇒ StrictTMVar m a → StrictTMVar n a Source #

newEmptySVar ∷ (MonadSTM m, NoThunks a) ⇒ a → m (StrictSVar m a) Source #

newSVar ∷ (MonadSTM m, HasCallStack, NoThunks a) ⇒ a → m (StrictSVar m a) Source #

Temporary

uncheckedNewSVarMonadSTM m ⇒ a → m (StrictSVar m a) Source #