ouroboros-consensus
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.Util.MonadSTM.NormalForm

Contents

Synopsis

Documentation

castStrictSVar ∷ ∀ (m ∷ Type → Type) (n ∷ Type → Type) a. (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 #

readSVar ∷ MonadSTM m ⇒ StrictSVar m a → m a Source #

readSVarSTM ∷ ∀ (m ∷ Type → Type) a. MonadSTM 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.

takeSVar ∷ MonadSTM m ⇒ StrictSVar m a → m a Source #

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

tryReadSVar ∷ MonadSTM m ⇒ StrictSVar m a → m (Maybe a) Source #

tryTakeSVar ∷ MonadSTM 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 #

data StrictSVar (m ∷ Type → Type) 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.

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

throwIO specialised to stm monad.

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

debugTraceTMVar ∷ ∀ (m ∷ Type → Type) a proxy. (MonadTraceSTM m, Show a) ⇒ proxy m → StrictTMVar m a → STM m () #

debugTraceTMVarIO ∷ (MonadTraceSTM m, Show a) ⇒ StrictTMVar m a → m () #

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

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

labelTMVar ∷ ∀ (m ∷ Type → Type) a. MonadLabelledSTM m ⇒ StrictTMVar m a → String → STM m () #

labelTMVarIO ∷ MonadLabelledSTM m ⇒ StrictTMVar m a → String → m () #

newEmptyTMVar ∷ ∀ (m ∷ Type → Type) a. MonadSTM m ⇒ STM m (StrictTMVar m a) #

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

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

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

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

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

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

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

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

type family InspectMonadSTM (m ∷ Type → Type) ∷ Type → Type Source #

class (MonadSTM m, Monad (InspectMonadSTM m)) ⇒ MonadInspectSTM (m ∷ Type → Type) 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 InspectMonadSTM (m ∷ Type → Type) ∷ Type → Type Source #

Methods

inspectTVar ∷ proxy m → TVar m a → InspectMonadSTM 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 → InspectMonadSTM m (Maybe a) Source #

Return the value of a TMVar as an InspectMonad computation.

Instances

Instances details
MonadInspectSTM IO Source # 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

Associated Types

type InspectMonadSTM IO 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

Methods

inspectTVar ∷ proxy IO → TVar IO a → InspectMonadSTM IO a Source #

inspectTMVar ∷ proxy IO → TMVar IO a → InspectMonadSTM IO (Maybe a) Source #

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

Defined in Ouroboros.Consensus.Util.EarlyExit

Associated Types

type InspectMonadSTM (WithEarlyExit m) 
Instance details

Defined in Ouroboros.Consensus.Util.EarlyExit

MonadInspectSTM m ⇒ MonadInspectSTM (ReaderT r m) Source # 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

Associated Types

type InspectMonadSTM (ReaderT r m) 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

Methods

inspectTVar ∷ proxy (ReaderT r m) → TVar (ReaderT r m) a → InspectMonadSTM (ReaderT r m) a Source #

inspectTMVar ∷ proxy (ReaderT r m) → TMVar (ReaderT r m) a → InspectMonadSTM (ReaderT r m) (Maybe a) Source #

class MonadSTM m ⇒ MonadLabelledSTM (m ∷ Type → Type) 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 Source #

noop instance

Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

Methods

labelTVar ∷ TVar IO a → String → STM IO () Source #

labelTMVar ∷ TMVar IO a → String → STM IO () Source #

labelTQueue ∷ TQueue IO a → String → STM IO () Source #

labelTBQueue ∷ TBQueue IO a → String → STM IO () Source #

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

labelTSem ∷ TSem IO → String → STM IO () Source #

labelTChan ∷ TChan IO a → String → STM IO () Source #

labelTVarIO ∷ TVar IO a → String → IO () Source #

labelTMVarIO ∷ TMVar IO a → String → IO () Source #

labelTQueueIO ∷ TQueue IO a → String → IO () Source #

labelTBQueueIO ∷ TBQueue IO a → String → IO () Source #

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

labelTSemIO ∷ TSem IO → String → IO () Source #

labelTChanIO ∷ TChan IO a → String → IO () Source #

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

Defined in Ouroboros.Consensus.Util.EarlyExit

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

The STM primitives parametrised by a monad m.

Associated Types

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

The STM monad.

Methods

atomically ∷ HasCallStack ⇒ STM m a → m a Source #

Atomically run an STM computation.

See atomically.

retry ∷ STM m a Source #

See retry.

orElse ∷ STM m a → STM m a → STM m a Source #

See orElse.

check ∷ Bool → STM m () Source #

See check.

Instances

Instances details
MonadSTM IO Source # 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

Associated Types

type STM IO 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

type STM IO = STM
type TVar IO 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

type TVar IO = TVar
type TMVar IO 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

type TMVar IO = TMVar
type TQueue IO 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

type TBQueue IO 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

type TArray IO 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

type TSem IO 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

type TSem IO = TSem
type TChan IO 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

type TChan IO = TChan

Methods

atomically ∷ HasCallStack ⇒ STM IO a → IO a Source #

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

readTVar ∷ TVar IO a → STM IO a Source #

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

retry ∷ STM IO a Source #

orElse ∷ STM IO a → STM IO a → STM IO a Source #

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

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

stateTVar ∷ TVar IO s → (s → (a, s)) → STM IO a Source #

swapTVar ∷ TVar IO a → a → STM IO a Source #

check ∷ Bool → STM IO () Source #

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

newEmptyTMVar ∷ STM IO (TMVar IO a) Source #

takeTMVar ∷ TMVar IO a → STM IO a Source #

tryTakeTMVar ∷ TMVar IO a → STM IO (Maybe a) Source #

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

tryPutTMVar ∷ TMVar IO a → a → STM IO Bool Source #

readTMVar ∷ TMVar IO a → STM IO a Source #

tryReadTMVar ∷ TMVar IO a → STM IO (Maybe a) Source #

swapTMVar ∷ TMVar IO a → a → STM IO a Source #

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

isEmptyTMVar ∷ TMVar IO a → STM IO Bool Source #

newTQueue ∷ STM IO (TQueue IO a) Source #

readTQueue ∷ TQueue IO a → STM IO a Source #

tryReadTQueue ∷ TQueue IO a → STM IO (Maybe a) Source #

peekTQueue ∷ TQueue IO a → STM IO a Source #

tryPeekTQueue ∷ TQueue IO a → STM IO (Maybe a) Source #

flushTQueue ∷ TQueue IO a → STM IO [a] Source #

writeTQueue ∷ TQueue IO a → a → STM IO () Source #

isEmptyTQueue ∷ TQueue IO a → STM IO Bool Source #

unGetTQueue ∷ TQueue IO a → a → STM IO () Source #

newTBQueue ∷ Natural → STM IO (TBQueue IO a) Source #

readTBQueue ∷ TBQueue IO a → STM IO a Source #

tryReadTBQueue ∷ TBQueue IO a → STM IO (Maybe a) Source #

peekTBQueue ∷ TBQueue IO a → STM IO a Source #

tryPeekTBQueue ∷ TBQueue IO a → STM IO (Maybe a) Source #

flushTBQueue ∷ TBQueue IO a → STM IO [a] Source #

writeTBQueue ∷ TBQueue IO a → a → STM IO () Source #

lengthTBQueue ∷ TBQueue IO a → STM IO Natural Source #

isEmptyTBQueue ∷ TBQueue IO a → STM IO Bool Source #

isFullTBQueue ∷ TBQueue IO a → STM IO Bool Source #

unGetTBQueue ∷ TBQueue IO a → a → STM IO () Source #

newTSem ∷ Integer → STM IO (TSem IO) Source #

waitTSem ∷ TSem IO → STM IO () Source #

signalTSem ∷ TSem IO → STM IO () Source #

signalTSemN ∷ Natural → TSem IO → STM IO () Source #

newTChan ∷ STM IO (TChan IO a) Source #

newBroadcastTChan ∷ STM IO (TChan IO a) Source #

dupTChan ∷ TChan IO a → STM IO (TChan IO a) Source #

cloneTChan ∷ TChan IO a → STM IO (TChan IO a) Source #

readTChan ∷ TChan IO a → STM IO a Source #

tryReadTChan ∷ TChan IO a → STM IO (Maybe a) Source #

peekTChan ∷ TChan IO a → STM IO a Source #

tryPeekTChan ∷ TChan IO a → STM IO (Maybe a) Source #

writeTChan ∷ TChan IO a → a → STM IO () Source #

unGetTChan ∷ TChan IO a → a → STM IO () Source #

isEmptyTChan ∷ TChan IO a → STM IO Bool Source #

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

readTVarIO ∷ TVar IO a → IO a Source #

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

newEmptyTMVarIO ∷ IO (TMVar IO a) Source #

newTQueueIO ∷ IO (TQueue IO a) Source #

newTBQueueIO ∷ Natural → IO (TBQueue IO a) Source #

newTChanIO ∷ IO (TChan IO a) Source #

newBroadcastTChanIO ∷ IO (TChan IO a) Source #

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

Defined in Ouroboros.Consensus.Util.EarlyExit

Associated Types

type STM (WithEarlyExit m) 
Instance details

Defined in Ouroboros.Consensus.Util.EarlyExit

type TVar (WithEarlyExit m) 
Instance details

Defined in Ouroboros.Consensus.Util.EarlyExit

type TVar (WithEarlyExit m) = TVar m
type TMVar (WithEarlyExit m) 
Instance details

Defined in Ouroboros.Consensus.Util.EarlyExit

type TQueue (WithEarlyExit m) 
Instance details

Defined in Ouroboros.Consensus.Util.EarlyExit

type TBQueue (WithEarlyExit m) 
Instance details

Defined in Ouroboros.Consensus.Util.EarlyExit

type TArray (WithEarlyExit m) 
Instance details

Defined in Ouroboros.Consensus.Util.EarlyExit

type TSem (WithEarlyExit m) 
Instance details

Defined in Ouroboros.Consensus.Util.EarlyExit

type TSem (WithEarlyExit m) = TSem m
type TChan (WithEarlyExit m) 
Instance details

Defined in Ouroboros.Consensus.Util.EarlyExit

Methods

atomically ∷ HasCallStack ⇒ STM (WithEarlyExit m) a → WithEarlyExit m a Source #

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

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

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

retry ∷ STM (WithEarlyExit m) a Source #

orElse ∷ STM (WithEarlyExit m) a → STM (WithEarlyExit m) a → STM (WithEarlyExit m) a Source #

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

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

stateTVar ∷ TVar (WithEarlyExit m) s → (s → (a, s)) → STM (WithEarlyExit m) a Source #

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

check ∷ Bool → STM (WithEarlyExit m) () Source #

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

newEmptyTMVar ∷ STM (WithEarlyExit m) (TMVar (WithEarlyExit m) a) Source #

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

tryTakeTMVar ∷ TMVar (WithEarlyExit m) a → STM (WithEarlyExit m) (Maybe a) Source #

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

tryPutTMVar ∷ TMVar (WithEarlyExit m) a → a → STM (WithEarlyExit m) Bool Source #

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

tryReadTMVar ∷ TMVar (WithEarlyExit m) a → STM (WithEarlyExit m) (Maybe a) Source #

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

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

isEmptyTMVar ∷ TMVar (WithEarlyExit m) a → STM (WithEarlyExit m) Bool Source #

newTQueue ∷ STM (WithEarlyExit m) (TQueue (WithEarlyExit m) a) Source #

readTQueue ∷ TQueue (WithEarlyExit m) a → STM (WithEarlyExit m) a Source #

tryReadTQueue ∷ TQueue (WithEarlyExit m) a → STM (WithEarlyExit m) (Maybe a) Source #

peekTQueue ∷ TQueue (WithEarlyExit m) a → STM (WithEarlyExit m) a Source #

tryPeekTQueue ∷ TQueue (WithEarlyExit m) a → STM (WithEarlyExit m) (Maybe a) Source #

flushTQueue ∷ TQueue (WithEarlyExit m) a → STM (WithEarlyExit m) [a] Source #

writeTQueue ∷ TQueue (WithEarlyExit m) a → a → STM (WithEarlyExit m) () Source #

isEmptyTQueue ∷ TQueue (WithEarlyExit m) a → STM (WithEarlyExit m) Bool Source #

unGetTQueue ∷ TQueue (WithEarlyExit m) a → a → STM (WithEarlyExit m) () Source #

newTBQueue ∷ Natural → STM (WithEarlyExit m) (TBQueue (WithEarlyExit m) a) Source #

readTBQueue ∷ TBQueue (WithEarlyExit m) a → STM (WithEarlyExit m) a Source #

tryReadTBQueue ∷ TBQueue (WithEarlyExit m) a → STM (WithEarlyExit m) (Maybe a) Source #

peekTBQueue ∷ TBQueue (WithEarlyExit m) a → STM (WithEarlyExit m) a Source #

tryPeekTBQueue ∷ TBQueue (WithEarlyExit m) a → STM (WithEarlyExit m) (Maybe a) Source #

flushTBQueue ∷ TBQueue (WithEarlyExit m) a → STM (WithEarlyExit m) [a] Source #

writeTBQueue ∷ TBQueue (WithEarlyExit m) a → a → STM (WithEarlyExit m) () Source #

lengthTBQueue ∷ TBQueue (WithEarlyExit m) a → STM (WithEarlyExit m) Natural Source #

isEmptyTBQueue ∷ TBQueue (WithEarlyExit m) a → STM (WithEarlyExit m) Bool Source #

isFullTBQueue ∷ TBQueue (WithEarlyExit m) a → STM (WithEarlyExit m) Bool Source #

unGetTBQueue ∷ TBQueue (WithEarlyExit m) a → a → STM (WithEarlyExit m) () Source #

newTSem ∷ Integer → STM (WithEarlyExit m) (TSem (WithEarlyExit m)) Source #

waitTSem ∷ TSem (WithEarlyExit m) → STM (WithEarlyExit m) () Source #

signalTSem ∷ TSem (WithEarlyExit m) → STM (WithEarlyExit m) () Source #

signalTSemN ∷ Natural → TSem (WithEarlyExit m) → STM (WithEarlyExit m) () Source #

newTChan ∷ STM (WithEarlyExit m) (TChan (WithEarlyExit m) a) Source #

newBroadcastTChan ∷ STM (WithEarlyExit m) (TChan (WithEarlyExit m) a) Source #

dupTChan ∷ TChan (WithEarlyExit m) a → STM (WithEarlyExit m) (TChan (WithEarlyExit m) a) Source #

cloneTChan ∷ TChan (WithEarlyExit m) a → STM (WithEarlyExit m) (TChan (WithEarlyExit m) a) Source #

readTChan ∷ TChan (WithEarlyExit m) a → STM (WithEarlyExit m) a Source #

tryReadTChan ∷ TChan (WithEarlyExit m) a → STM (WithEarlyExit m) (Maybe a) Source #

peekTChan ∷ TChan (WithEarlyExit m) a → STM (WithEarlyExit m) a Source #

tryPeekTChan ∷ TChan (WithEarlyExit m) a → STM (WithEarlyExit m) (Maybe a) Source #

writeTChan ∷ TChan (WithEarlyExit m) a → a → STM (WithEarlyExit m) () Source #

unGetTChan ∷ TChan (WithEarlyExit m) a → a → STM (WithEarlyExit m) () Source #

isEmptyTChan ∷ TChan (WithEarlyExit m) a → STM (WithEarlyExit m) Bool Source #

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

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

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

newEmptyTMVarIO ∷ WithEarlyExit m (TMVar (WithEarlyExit m) a) Source #

newTQueueIO ∷ WithEarlyExit m (TQueue (WithEarlyExit m) a) Source #

newTBQueueIO ∷ Natural → WithEarlyExit m (TBQueue (WithEarlyExit m) a) Source #

newTChanIO ∷ WithEarlyExit m (TChan (WithEarlyExit m) a) Source #

newBroadcastTChanIO ∷ WithEarlyExit m (TChan (WithEarlyExit m) a) Source #

MonadSTM m ⇒ MonadSTM (ReaderT r m) Source #

The underlying stm monad is also transformed.

Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

Associated Types

type STM (ReaderT r m) 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

type STM (ReaderT r m) = ReaderT r (STM m)
type TVar (ReaderT r m) 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

type TVar (ReaderT r m) = TVar m
type TMVar (ReaderT r m) 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

type TMVar (ReaderT r m) = TMVar m
type TQueue (ReaderT r m) 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

type TQueue (ReaderT r m) = TQueue m
type TBQueue (ReaderT r m) 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

type TBQueue (ReaderT r m) = TBQueue m
type TArray (ReaderT r m) 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

type TArray (ReaderT r m) = TArray m
type TSem (ReaderT r m) 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

type TSem (ReaderT r m) = TSem m
type TChan (ReaderT r m) 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

type TChan (ReaderT r m) = TChan m

Methods

atomically ∷ HasCallStack ⇒ STM (ReaderT r m) a → ReaderT r m a Source #

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

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

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

retry ∷ STM (ReaderT r m) a Source #

orElse ∷ STM (ReaderT r m) a → STM (ReaderT r m) a → STM (ReaderT r m) a Source #

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

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

stateTVar ∷ TVar (ReaderT r m) s → (s → (a, s)) → STM (ReaderT r m) a Source #

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

check ∷ Bool → STM (ReaderT r m) () Source #

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

newEmptyTMVar ∷ STM (ReaderT r m) (TMVar (ReaderT r m) a) Source #

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

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

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

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

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

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

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

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

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

newTQueue ∷ STM (ReaderT r m) (TQueue (ReaderT r m) a) Source #

readTQueue ∷ TQueue (ReaderT r m) a → STM (ReaderT r m) a Source #

tryReadTQueue ∷ TQueue (ReaderT r m) a → STM (ReaderT r m) (Maybe a) Source #

peekTQueue ∷ TQueue (ReaderT r m) a → STM (ReaderT r m) a Source #

tryPeekTQueue ∷ TQueue (ReaderT r m) a → STM (ReaderT r m) (Maybe a) Source #

flushTQueue ∷ TQueue (ReaderT r m) a → STM (ReaderT r m) [a] Source #

writeTQueue ∷ TQueue (ReaderT r m) a → a → STM (ReaderT r m) () Source #

isEmptyTQueue ∷ TQueue (ReaderT r m) a → STM (ReaderT r m) Bool Source #

unGetTQueue ∷ TQueue (ReaderT r m) a → a → STM (ReaderT r m) () Source #

newTBQueue ∷ Natural → STM (ReaderT r m) (TBQueue (ReaderT r m) a) Source #

readTBQueue ∷ TBQueue (ReaderT r m) a → STM (ReaderT r m) a Source #

tryReadTBQueue ∷ TBQueue (ReaderT r m) a → STM (ReaderT r m) (Maybe a) Source #

peekTBQueue ∷ TBQueue (ReaderT r m) a → STM (ReaderT r m) a Source #

tryPeekTBQueue ∷ TBQueue (ReaderT r m) a → STM (ReaderT r m) (Maybe a) Source #

flushTBQueue ∷ TBQueue (ReaderT r m) a → STM (ReaderT r m) [a] Source #

writeTBQueue ∷ TBQueue (ReaderT r m) a → a → STM (ReaderT r m) () Source #

lengthTBQueue ∷ TBQueue (ReaderT r m) a → STM (ReaderT r m) Natural Source #

isEmptyTBQueue ∷ TBQueue (ReaderT r m) a → STM (ReaderT r m) Bool Source #

isFullTBQueue ∷ TBQueue (ReaderT r m) a → STM (ReaderT r m) Bool Source #

unGetTBQueue ∷ TBQueue (ReaderT r m) a → a → STM (ReaderT r m) () Source #

newTSem ∷ Integer → STM (ReaderT r m) (TSem (ReaderT r m)) Source #

waitTSem ∷ TSem (ReaderT r m) → STM (ReaderT r m) () Source #

signalTSem ∷ TSem (ReaderT r m) → STM (ReaderT r m) () Source #

signalTSemN ∷ Natural → TSem (ReaderT r m) → STM (ReaderT r m) () Source #

newTChan ∷ STM (ReaderT r m) (TChan (ReaderT r m) a) Source #

newBroadcastTChan ∷ STM (ReaderT r m) (TChan (ReaderT r m) a) Source #

dupTChan ∷ TChan (ReaderT r m) a → STM (ReaderT r m) (TChan (ReaderT r m) a) Source #

cloneTChan ∷ TChan (ReaderT r m) a → STM (ReaderT r m) (TChan (ReaderT r m) a) Source #

readTChan ∷ TChan (ReaderT r m) a → STM (ReaderT r m) a Source #

tryReadTChan ∷ TChan (ReaderT r m) a → STM (ReaderT r m) (Maybe a) Source #

peekTChan ∷ TChan (ReaderT r m) a → STM (ReaderT r m) a Source #

tryPeekTChan ∷ TChan (ReaderT r m) a → STM (ReaderT r m) (Maybe a) Source #

writeTChan ∷ TChan (ReaderT r m) a → a → STM (ReaderT r m) () Source #

unGetTChan ∷ TChan (ReaderT r m) a → a → STM (ReaderT r m) () Source #

isEmptyTChan ∷ TChan (ReaderT r m) a → STM (ReaderT r m) Bool Source #

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

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

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

newEmptyTMVarIO ∷ ReaderT r m (TMVar (ReaderT r m) a) Source #

newTQueueIO ∷ ReaderT r m (TQueue (ReaderT r m) a) Source #

newTBQueueIO ∷ Natural → ReaderT r m (TBQueue (ReaderT r m) a) Source #

newTChanIO ∷ ReaderT r m (TChan (ReaderT r m) a) Source #

newBroadcastTChanIO ∷ ReaderT r m (TChan (ReaderT r m) a) Source #

class MonadInspectSTM m ⇒ MonadTraceSTM (m ∷ Type → Type) 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 → InspectMonadSTM m TraceValue) → STM m () Source #

default traceTMVar ∷ TMVar m a ~ TMVarDefault m a ⇒ proxy m → TMVar m a → (Maybe (Maybe a) → Maybe a → InspectMonadSTM m TraceValue) → STM m () Source #

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

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

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

default traceTSem ∷ TSem m ~ TSemDefault m ⇒ proxy m → TSem m → (Maybe Integer → Integer → InspectMonadSTM m TraceValue) → STM m () Source #

traceTMVarIO ∷ TMVar m a → (Maybe (Maybe a) → Maybe a → InspectMonadSTM m TraceValue) → m () Source #

default traceTMVarIO ∷ TMVar m a → (Maybe (Maybe a) → Maybe a → InspectMonadSTM m TraceValue) → m () Source #

traceTQueueIO ∷ TQueue m a → (Maybe [a] → [a] → InspectMonadSTM m TraceValue) → m () Source #

default traceTQueueIO ∷ TQueue m a → (Maybe [a] → [a] → InspectMonadSTM m TraceValue) → m () Source #

traceTBQueueIO ∷ TBQueue m a → (Maybe [a] → [a] → InspectMonadSTM m TraceValue) → m () Source #

default traceTBQueueIO ∷ TBQueue m a → (Maybe [a] → [a] → InspectMonadSTM m TraceValue) → m () Source #

traceTSemIO ∷ TSem m → (Maybe Integer → Integer → InspectMonadSTM m TraceValue) → m () Source #

default traceTSemIO ∷ TSem m → (Maybe Integer → Integer → InspectMonadSTM m TraceValue) → m () Source #

Instances

Instances details
MonadTraceSTM IO Source #

noop instance

Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

Methods

traceTVar ∷ proxy IO → TVar IO a → (Maybe a → a → InspectMonadSTM IO TraceValue) → STM IO () Source #

traceTMVar ∷ proxy IO → TMVar IO a → (Maybe (Maybe a) → Maybe a → InspectMonadSTM IO TraceValue) → STM IO () Source #

traceTQueue ∷ proxy IO → TQueue IO a → (Maybe [a] → [a] → InspectMonadSTM IO TraceValue) → STM IO () Source #

traceTBQueue ∷ proxy IO → TBQueue IO a → (Maybe [a] → [a] → InspectMonadSTM IO TraceValue) → STM IO () Source #

traceTSem ∷ proxy IO → TSem IO → (Maybe Integer → Integer → InspectMonadSTM IO TraceValue) → STM IO () Source #

traceTVarIO ∷ TVar IO a → (Maybe a → a → InspectMonadSTM IO TraceValue) → IO () Source #

traceTMVarIO ∷ TMVar IO a → (Maybe (Maybe a) → Maybe a → InspectMonadSTM IO TraceValue) → IO () Source #

traceTQueueIO ∷ TQueue IO a → (Maybe [a] → [a] → InspectMonadSTM IO TraceValue) → IO () Source #

traceTBQueueIO ∷ TBQueue IO a → (Maybe [a] → [a] → InspectMonadSTM IO TraceValue) → IO () Source #

traceTSemIO ∷ TSem IO → (Maybe Integer → Integer → InspectMonadSTM 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 → InspectMonadSTM (WithEarlyExit m) TraceValue) → STM (WithEarlyExit m) () Source #

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

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

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

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

traceTVarIO ∷ TVar (WithEarlyExit m) a → (Maybe a → a → InspectMonadSTM (WithEarlyExit m) TraceValue) → WithEarlyExit m () Source #

traceTMVarIO ∷ TMVar (WithEarlyExit m) a → (Maybe (Maybe a) → Maybe a → InspectMonadSTM (WithEarlyExit m) TraceValue) → WithEarlyExit m () Source #

traceTQueueIO ∷ TQueue (WithEarlyExit m) a → (Maybe [a] → [a] → InspectMonadSTM (WithEarlyExit m) TraceValue) → WithEarlyExit m () Source #

traceTBQueueIO ∷ TBQueue (WithEarlyExit m) a → (Maybe [a] → [a] → InspectMonadSTM (WithEarlyExit m) TraceValue) → WithEarlyExit m () Source #

traceTSemIO ∷ TSem (WithEarlyExit m) → (Maybe Integer → Integer → InspectMonadSTM (WithEarlyExit m) TraceValue) → WithEarlyExit m () Source #

MonadTraceSTM m ⇒ MonadTraceSTM (ReaderT r m) Source # 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

Methods

traceTVar ∷ proxy (ReaderT r m) → TVar (ReaderT r m) a → (Maybe a → a → InspectMonadSTM (ReaderT r m) TraceValue) → STM (ReaderT r m) () Source #

traceTMVar ∷ proxy (ReaderT r m) → TMVar (ReaderT r m) a → (Maybe (Maybe a) → Maybe a → InspectMonadSTM (ReaderT r m) TraceValue) → STM (ReaderT r m) () Source #

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

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

traceTSem ∷ proxy (ReaderT r m) → TSem (ReaderT r m) → (Maybe Integer → Integer → InspectMonadSTM (ReaderT r m) TraceValue) → STM (ReaderT r m) () Source #

traceTVarIO ∷ TVar (ReaderT r m) a → (Maybe a → a → InspectMonadSTM (ReaderT r m) TraceValue) → ReaderT r m () Source #

traceTMVarIO ∷ TMVar (ReaderT r m) a → (Maybe (Maybe a) → Maybe a → InspectMonadSTM (ReaderT r m) TraceValue) → ReaderT r m () Source #

traceTQueueIO ∷ TQueue (ReaderT r m) a → (Maybe [a] → [a] → InspectMonadSTM (ReaderT r m) TraceValue) → ReaderT r m () Source #

traceTBQueueIO ∷ TBQueue (ReaderT r m) a → (Maybe [a] → [a] → InspectMonadSTM (ReaderT r m) TraceValue) → ReaderT r m () Source #

traceTSemIO ∷ TSem (ReaderT r m) → (Maybe Integer → Integer → InspectMonadSTM (ReaderT r m) TraceValue) → ReaderT r m () Source #

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

The STM monad.

Instances

Instances details
type STM IO Source # 
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) Source # 
Instance details

Defined in Control.Monad.Class.MonadSTM.Internal

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

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 DontTrace ∷ TraceValue

Do not trace the value.

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

Use only a dynamic tracer.

pattern TraceString ∷ String → TraceValue

Use only string tracing.

type LazyTMVar (m ∷ Type → Type) = TMVar m #

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

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

Temporary

uncheckedNewSVar ∷ MonadSTM m ⇒ a → m (StrictSVar m a) Source #