ouroboros-consensus-0.1.0.1: Consensus layer for the Ouroboros blockchain protocol
Safe Haskell None
Language Haskell2010

Ouroboros.Consensus.Util.IOLike

Synopsis

Documentation

Re-exports

MonadThrow

class ( Typeable e, Show e) => Exception e where Source #

Any type that you wish to throw or catch as an exception must be an instance of the Exception class. The simplest case is a new exception type directly below the root:

data MyException = ThisException | ThatException
    deriving Show

instance Exception MyException

The default method definitions in the Exception class do what we need in this case. You can now throw and catch ThisException and ThatException as exceptions:

*Main> throw ThisException `catch` \e -> putStrLn ("Caught " ++ show (e :: MyException))
Caught ThisException

In more complicated examples, you may wish to define a whole hierarchy of exceptions:

---------------------------------------------------------------------
-- Make the root exception type for all the exceptions in a compiler

data SomeCompilerException = forall e . Exception e => SomeCompilerException e

instance Show SomeCompilerException where
    show (SomeCompilerException e) = show e

instance Exception SomeCompilerException

compilerExceptionToException :: Exception e => e -> SomeException
compilerExceptionToException = toException . SomeCompilerException

compilerExceptionFromException :: Exception e => SomeException -> Maybe e
compilerExceptionFromException x = do
    SomeCompilerException a <- fromException x
    cast a

---------------------------------------------------------------------
-- Make a subhierarchy for exceptions in the frontend of the compiler

data SomeFrontendException = forall e . Exception e => SomeFrontendException e

instance Show SomeFrontendException where
    show (SomeFrontendException e) = show e

instance Exception SomeFrontendException where
    toException = compilerExceptionToException
    fromException = compilerExceptionFromException

frontendExceptionToException :: Exception e => e -> SomeException
frontendExceptionToException = toException . SomeFrontendException

frontendExceptionFromException :: Exception e => SomeException -> Maybe e
frontendExceptionFromException x = do
    SomeFrontendException a <- fromException x
    cast a

---------------------------------------------------------------------
-- Make an exception type for a particular frontend compiler exception

data MismatchedParentheses = MismatchedParentheses
    deriving Show

instance Exception MismatchedParentheses where
    toException   = frontendExceptionToException
    fromException = frontendExceptionFromException

We can now catch a MismatchedParentheses exception as MismatchedParentheses , SomeFrontendException or SomeCompilerException , but not other types, e.g. IOException :

*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: MismatchedParentheses))
Caught MismatchedParentheses
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeFrontendException))
Caught MismatchedParentheses
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeCompilerException))
Caught MismatchedParentheses
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: IOException))
*** Exception: MismatchedParentheses

Minimal complete definition

Nothing

Methods

toException :: e -> SomeException Source #

fromException :: SomeException -> Maybe e Source #

displayException :: e -> String Source #

Render this exception value in a human-friendly manner.

Default implementation: show .

Since: base-4.8.0.0

Instances

Instances details
Exception AsyncCancelled
Instance details

Defined in Control.Concurrent.Async

Exception ExceptionInLinkedThread
Instance details

Defined in Control.Concurrent.Async

Exception Void

Since: base-4.8.0.0

Instance details

Defined in Data.Void

Exception PatternMatchFail

Since: base-4.0

Instance details

Defined in Control.Exception.Base

Exception RecSelError

Since: base-4.0

Instance details

Defined in Control.Exception.Base

Exception RecConError

Since: base-4.0

Instance details

Defined in Control.Exception.Base

Exception RecUpdError

Since: base-4.0

Instance details

Defined in Control.Exception.Base

Exception NoMethodError

Since: base-4.0

Instance details

Defined in Control.Exception.Base

Exception TypeError

Since: base-4.9.0.0

Instance details

Defined in Control.Exception.Base

Exception NonTermination

Since: base-4.0

Instance details

Defined in Control.Exception.Base

Exception NestedAtomically

Since: base-4.0

Instance details

Defined in Control.Exception.Base

Exception BlockedIndefinitelyOnMVar

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception BlockedIndefinitelyOnSTM

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception Deadlock

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception AllocationLimitExceeded

Since: base-4.8.0.0

Instance details

Defined in GHC.IO.Exception

Exception CompactionFailed

Since: base-4.10.0.0

Instance details

Defined in GHC.IO.Exception

Exception AssertionFailed

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception SomeAsyncException

Since: base-4.7.0.0

Instance details

Defined in GHC.IO.Exception

Exception AsyncException

Since: base-4.7.0.0

Instance details

Defined in GHC.IO.Exception

Exception ArrayException

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception FixIOException

Since: base-4.11.0.0

Instance details

Defined in GHC.IO.Exception

Exception ExitCode

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception IOException

Since: base-4.1.0.0

Instance details

Defined in GHC.IO.Exception

Exception ErrorCall

Since: base-4.0.0.0

Instance details

Defined in GHC.Exception

Exception ArithException

Since: base-4.0.0.0

Instance details

Defined in GHC.Exception.Type

Exception SomeException

Since: base-3.0

Instance details

Defined in GHC.Exception.Type

Exception ASCII7_Invalid
Instance details

Defined in Basement.String.Encoding.ASCII7

Exception ISO_8859_1_Invalid
Instance details

Defined in Basement.String.Encoding.ISO_8859_1

Exception UTF16_Invalid
Instance details

Defined in Basement.String.Encoding.UTF16

Exception UTF32_Invalid
Instance details

Defined in Basement.String.Encoding.UTF32

Exception DeserialiseFailure
Instance details

Defined in Codec.CBOR.Read

Exception DecoderError
Instance details

Defined in Cardano.Binary.FromCBOR

Exception SeedBytesExhausted
Instance details

Defined in Cardano.Crypto.Seed

Exception CryptoError
Instance details

Defined in Crypto.Error.Types

Exception DNSError
Instance details

Defined in Network.DNS.Types

Exception ExceptionInLinkedThread
Instance details

Defined in Control.Monad.Class.MonadAsync

Exception DataMeasureClassOverflowException
Instance details

Defined in Data.Measure.Class

Exception MuxError
Instance details

Defined in Network.Mux.Trace

Exception MuxRuntimeError
Instance details

Defined in Network.Mux.Types

Exception TxSubmissionProtocolError
Instance details

Defined in Ouroboros.Network.TxSubmission.Outbound

Exception TxSubmissionProtocolError
Instance details

Defined in Ouroboros.Network.TxSubmission.Inbound

Exception KeepAliveProtocolFailure
Instance details

Defined in Ouroboros.Network.Protocol.KeepAlive.Type

Exception BlockFetchProtocolFailure
Instance details

Defined in Ouroboros.Network.BlockFetch.Client

Exception ProtocolLimitFailure
Instance details

Defined in Ouroboros.Network.Driver.Limits

Exception DecoderFailure
Instance details

Defined in Ouroboros.Network.Driver.Simple

Exception SubscriberError
Instance details

Defined in Ouroboros.Network.Subscription.Worker

Exception CodecFailure
Instance details

Defined in Network.TypedProtocol.Codec

Exception FsError Source #
Instance details

Defined in Ouroboros.Consensus.Storage.FS.API.Types

Exception BlockedIndefinitely
Instance details

Defined in Control.Monad.Class.MonadSTM

Exception BimapException
Instance details

Defined in Data.Bimap

Exception DbMarkerError Source #
Instance details

Defined in Ouroboros.Consensus.Node.DbMarker

Exception DbLocked Source #
Instance details

Defined in Ouroboros.Consensus.Node.DbLock

Exception ChunkAssertionFailure Source #
Instance details

Defined in Ouroboros.Consensus.Storage.ImmutableDB.Chunks.Internal

Exception OutsideForecastRange Source #
Instance details

Defined in Ouroboros.Consensus.Forecast

Exception ResourceRegistryThreadException Source #
Instance details

Defined in Ouroboros.Consensus.Util.ResourceRegistry

Exception TempRegistryException Source #
Instance details

Defined in Ouroboros.Consensus.Util.ResourceRegistry

Exception RegistryClosedException Source #
Instance details

Defined in Ouroboros.Consensus.Util.ResourceRegistry

Exception PastHorizonException Source #
Instance details

Defined in Ouroboros.Consensus.HardFork.History.Qry

Exception SystemClockMovedBackException Source #
Instance details

Defined in Ouroboros.Consensus.BlockchainTime.WallClock.Util

Exception VersionError Source #
Instance details

Defined in Ouroboros.Consensus.Util.Versioned

Exception HardForkEncoderException Source #
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Serialisation.Common

Exception ChainSyncClientException Source #
Instance details

Defined in Ouroboros.Consensus.MiniProtocol.ChainSync.Client

Exception BlockFetchServerException Source #
Instance details

Defined in Ouroboros.Consensus.MiniProtocol.BlockFetch.Server

( Typeable ntnAddr, Show ntnAddr) => Exception ( Failure ntnAddr)
Instance details

Defined in Ouroboros.Network.Diffusion.Common

( Typeable vNumber, Show vNumber) => Exception ( RefuseReason vNumber)
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

( Typeable vNumber, Show vNumber) => Exception ( HandshakeProtocolError vNumber)
Instance details

Defined in Ouroboros.Network.Protocol.Handshake.Type

( StandardHash blk, Typeable blk) => Exception ( VolatileDBError blk) Source #
Instance details

Defined in Ouroboros.Consensus.Storage.VolatileDB.API

( StandardHash blk, Typeable blk) => Exception ( ImmutableDBError blk) Source #
Instance details

Defined in Ouroboros.Consensus.Storage.ImmutableDB.API

( Typeable blk, StandardHash blk) => Exception ( ChainDbError blk) Source #
Instance details

Defined in Ouroboros.Consensus.Storage.ChainDB.API

( Typeable blk, StandardHash blk) => Exception ( ChainDbFailure blk) Source #
Instance details

Defined in Ouroboros.Consensus.Storage.ChainDB.API

class MonadThrow m => MonadCatch (m :: Type -> Type ) where Source #

Catching exceptions.

Covers standard utilities to respond to exceptions.

Minimal complete definition

catch

Methods

catch :: Exception e => m a -> (e -> m a) -> m a Source #

catchJust :: Exception e => (e -> Maybe b) -> m a -> (b -> m a) -> m a Source #

try :: Exception e => m a -> m ( Either e a) Source #

tryJust :: Exception e => (e -> Maybe b) -> m a -> m ( Either b a) Source #

handle :: Exception e => (e -> m a) -> m a -> m a Source #

handleJust :: Exception e => (e -> Maybe b) -> (b -> m a) -> m a -> m a Source #

onException :: m a -> m b -> m a Source #

bracketOnError :: m a -> (a -> m b) -> (a -> m c) -> m c Source #

generalBracket :: m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c) Source #

Instances

Instances details
MonadCatch IO
Instance details

Defined in Control.Monad.Class.MonadThrow

MonadCatch STM
Instance details

Defined in Control.Monad.Class.MonadThrow

MonadCatch m => MonadCatch ( WithEarlyExit m) Source #
Instance details

Defined in Ouroboros.Consensus.Util.EarlyExit

MonadCatch m => MonadCatch ( ReaderT r m)
Instance details

Defined in Control.Monad.Class.MonadThrow

MonadCatch m => MonadCatch ( ExceptT e m)
Instance details

Defined in Control.Monad.Class.MonadThrow

MonadCatch m => MonadCatch ( WithTempRegistry st m) Source #
Instance details

Defined in Ouroboros.Consensus.Util.ResourceRegistry

( MonadSTM m, MonadThrow ( STM m), MonadCatch ( STM m)) => MonadCatch ( WrappedSTM t r m)
Instance details

Defined in Control.Monad.Class.MonadSTM

class MonadCatch m => MonadMask (m :: Type -> Type ) where Source #

Support for safely working in the presence of asynchronous exceptions.

This is typically not needed directly as the utilities in MonadThrow and MonadCatch cover most use cases.

Minimal complete definition

mask , uninterruptibleMask

Methods

mask :: (( forall a. m a -> m a) -> m b) -> m b Source #

uninterruptibleMask :: (( forall a. m a -> m a) -> m b) -> m b Source #

mask_ :: m a -> m a Source #

uninterruptibleMask_ :: m a -> m a Source #

Instances

Instances details
MonadMask IO
Instance details

Defined in Control.Monad.Class.MonadThrow

MonadMask m => MonadMask ( WithEarlyExit m) Source #
Instance details

Defined in Ouroboros.Consensus.Util.EarlyExit

MonadMask m => MonadMask ( ReaderT r m)
Instance details

Defined in Control.Monad.Class.MonadThrow

MonadMask m => MonadMask ( ExceptT e m)
Instance details

Defined in Control.Monad.Class.MonadThrow

MonadMask m => MonadMask ( WithTempRegistry st m) Source #
Instance details

Defined in Ouroboros.Consensus.Util.ResourceRegistry

class Monad m => MonadThrow (m :: Type -> Type ) where Source #

Throwing exceptions, and resource handling in the presence of exceptions.

Does not include the ability to respond to exceptions.

Minimal complete definition

throwIO

Methods

throwIO :: Exception e => e -> m a Source #

bracket :: m a -> (a -> m b) -> (a -> m c) -> m c Source #

bracket_ :: m a -> m b -> m c -> m c Source #

finally :: m a -> m b -> m a Source #

Instances

Instances details
MonadThrow IO
Instance details

Defined in Control.Monad.Class.MonadThrow

MonadThrow STM
Instance details

Defined in Control.Monad.Class.MonadThrow

MonadCatch m => MonadThrow ( WithEarlyExit m) Source #
Instance details

Defined in Ouroboros.Consensus.Util.EarlyExit

MonadThrow m => MonadThrow ( ReaderT r m)
Instance details

Defined in Control.Monad.Class.MonadThrow

MonadCatch m => MonadThrow ( ExceptT e m)
Instance details

Defined in Control.Monad.Class.MonadThrow

MonadThrow m => MonadThrow ( WithTempRegistry st m) Source #
Instance details

Defined in Ouroboros.Consensus.Util.ResourceRegistry

( MonadSTM m, MonadThrow ( STM m), MonadCatch ( STM m)) => MonadThrow ( WrappedSTM t r m)
Instance details

Defined in Control.Monad.Class.MonadSTM

data SomeException Source #

The SomeException type is the root of the exception type hierarchy. When an exception of type e is thrown, behind the scenes it is encapsulated in a SomeException .

MonadSTM

MonadFork, TODO: Should we hide this in favour of MonadAsync?

class MonadThread m => MonadFork (m :: Type -> Type ) where Source #

Minimal complete definition

forkIO , forkIOWithUnmask , throwTo , yield

labelThisThread :: MonadThread m => String -> m () Source #

Apply the label to the current thread

MonadAsync

data ExceptionInLinkedThread Source #

Exception from child thread re-raised in parent thread

We record the thread ID of the child thread as a String . This avoids an m parameter in the type, which is important: ExceptionInLinkedThread must be an instance of Exception , requiring it to be Typeable ; if m appeared in the type, we would require m to be Typeable , which does not work with with the simulator, as it would require a Typeable constraint on the s parameter of IOSim .

class ( MonadSTM m, MonadThread m) => MonadAsync (m :: Type -> Type ) where Source #

Associated Types

type Async (m :: Type -> Type ) = (async :: Type -> Type ) | async -> m Source #

An asynchronous action

Methods

async :: m a -> m ( Async m a) Source #

asyncThreadId :: Async m a -> ThreadId m Source #

withAsync :: m a -> ( Async m a -> m b) -> m b Source #

waitSTM :: Async m a -> STM m a Source #

pollSTM :: Async m a -> STM m ( Maybe ( Either SomeException a)) Source #

waitCatchSTM :: Async m a -> STM m ( Either SomeException a) Source #

waitAnySTM :: [ Async m a] -> STM m ( Async m a, a) Source #

waitAnyCatchSTM :: [ Async m a] -> STM m ( Async m a, Either SomeException a) Source #

waitEitherSTM :: Async m a -> Async m b -> STM m ( Either a b) Source #

waitEitherSTM_ :: Async m a -> Async m b -> STM m () Source #

waitEitherCatchSTM :: Async m a -> Async m b -> STM m ( Either ( Either SomeException a) ( Either SomeException b)) Source #

waitBothSTM :: Async m a -> Async m b -> STM m (a, b) Source #

wait :: Async m a -> m a Source #

poll :: Async m a -> m ( Maybe ( Either SomeException a)) Source #

waitCatch :: Async m a -> m ( Either SomeException a) Source #

cancel :: Async m a -> m () Source #

cancelWith :: Exception e => Async m a -> e -> m () Source #

uninterruptibleCancel :: Async m a -> m () Source #

waitAny :: [ Async m a] -> m ( Async m a, a) Source #

waitAnyCatch :: [ Async m a] -> m ( Async m a, Either SomeException a) Source #

waitAnyCancel :: [ Async m a] -> m ( Async m a, a) Source #

waitAnyCatchCancel :: [ Async m a] -> m ( Async m a, Either SomeException a) Source #

waitEither :: Async m a -> Async m b -> m ( Either a b) Source #

waitEitherCatch :: Async m a -> Async m b -> m ( Either ( Either SomeException a) ( Either SomeException b)) Source #

Note, IO-based implementations should override the default implementation. See the async package implementation and comments. http://hackage.haskell.org/package/async-2.2.1/docs/src/Control.Concurrent.Async.html#waitEitherCatch

waitEitherCancel :: Async m a -> Async m b -> m ( Either a b) Source #

waitEitherCatchCancel :: Async m a -> Async m b -> m ( Either ( Either SomeException a) ( Either SomeException b)) Source #

waitEither_ :: Async m a -> Async m b -> m () Source #

waitBoth :: Async m a -> Async m b -> m (a, b) Source #

race :: m a -> m b -> m ( Either a b) Source #

race_ :: m a -> m b -> m () Source #

concurrently :: m a -> m b -> m (a, b) Source #

concurrently_ :: m a -> m b -> m () Source #

asyncWithUnmask :: (( forall b. m b -> m b) -> m a) -> m ( Async m a) Source #

Instances

Instances details
MonadAsync IO
Instance details

Defined in Control.Monad.Class.MonadAsync

Associated Types

type Async IO = (async :: Type -> Type ) Source #

Methods

async :: IO a -> IO ( Async IO a) Source #

asyncThreadId :: Async IO a -> ThreadId IO Source #

withAsync :: IO a -> ( Async IO a -> IO b) -> IO b Source #

waitSTM :: Async IO a -> STM IO a Source #

pollSTM :: Async IO a -> STM IO ( Maybe ( Either SomeException a)) Source #

waitCatchSTM :: Async IO a -> STM IO ( Either SomeException a) Source #

waitAnySTM :: [ Async IO a] -> STM IO ( Async IO a, a) Source #

waitAnyCatchSTM :: [ Async IO a] -> STM IO ( Async IO a, Either SomeException a) Source #

waitEitherSTM :: Async IO a -> Async IO b -> STM IO ( Either a b) Source #

waitEitherSTM_ :: Async IO a -> Async IO b -> STM IO () Source #

waitEitherCatchSTM :: Async IO a -> Async IO b -> STM IO ( Either ( Either SomeException a) ( Either SomeException b)) Source #

waitBothSTM :: Async IO a -> Async IO b -> STM IO (a, b) Source #

wait :: Async IO a -> IO a Source #

poll :: Async IO a -> IO ( Maybe ( Either SomeException a)) Source #

waitCatch :: Async IO a -> IO ( Either SomeException a) Source #

cancel :: Async IO a -> IO () Source #

cancelWith :: Exception e => Async IO a -> e -> IO () Source #

uninterruptibleCancel :: Async IO a -> IO () Source #

waitAny :: [ Async IO a] -> IO ( Async IO a, a) Source #

waitAnyCatch :: [ Async IO a] -> IO ( Async IO a, Either SomeException a) Source #

waitAnyCancel :: [ Async IO a] -> IO ( Async IO a, a) Source #

waitAnyCatchCancel :: [ Async IO a] -> IO ( Async IO a, Either SomeException a) Source #

waitEither :: Async IO a -> Async IO b -> IO ( Either a b) Source #

waitEitherCatch :: Async IO a -> Async IO b -> IO ( Either ( Either SomeException a) ( Either SomeException b)) Source #

waitEitherCancel :: Async IO a -> Async IO b -> IO ( Either a b) Source #

waitEitherCatchCancel :: Async IO a -> Async IO b -> IO ( Either ( Either SomeException a) ( Either SomeException b)) Source #

waitEither_ :: Async IO a -> Async IO b -> IO () Source #

waitBoth :: Async IO a -> Async IO b -> IO (a, b) Source #

race :: IO a -> IO b -> IO ( Either a b) Source #

race_ :: IO a -> IO b -> IO () Source #

concurrently :: IO a -> IO b -> IO (a, b) Source #

concurrently_ :: IO a -> IO b -> IO () Source #

asyncWithUnmask :: (( forall b. IO b -> IO b) -> IO a) -> IO ( Async IO a) Source #

( MonadMask m, MonadAsync m, MonadCatch ( STM m)) => MonadAsync ( WithEarlyExit m) Source #
Instance details

Defined in Ouroboros.Consensus.Util.EarlyExit

Associated Types

type Async ( WithEarlyExit m) = (async :: Type -> Type ) Source #

Methods

async :: WithEarlyExit m a -> WithEarlyExit m ( Async ( WithEarlyExit m) a) Source #

asyncThreadId :: Async ( WithEarlyExit m) a -> ThreadId ( WithEarlyExit m) Source #

withAsync :: WithEarlyExit m a -> ( Async ( WithEarlyExit m) a -> WithEarlyExit m b) -> WithEarlyExit m b Source #

waitSTM :: Async ( WithEarlyExit m) a -> STM ( WithEarlyExit m) a Source #

pollSTM :: Async ( WithEarlyExit m) a -> STM ( WithEarlyExit m) ( Maybe ( Either SomeException a)) Source #

waitCatchSTM :: Async ( WithEarlyExit m) a -> STM ( WithEarlyExit m) ( Either SomeException a) Source #

waitAnySTM :: [ Async ( WithEarlyExit m) a] -> STM ( WithEarlyExit m) ( Async ( WithEarlyExit m) a, a) Source #

waitAnyCatchSTM :: [ Async ( WithEarlyExit m) a] -> STM ( WithEarlyExit m) ( Async ( WithEarlyExit m) a, Either SomeException a) Source #

waitEitherSTM :: Async ( WithEarlyExit m) a -> Async ( WithEarlyExit m) b -> STM ( WithEarlyExit m) ( Either a b) Source #

waitEitherSTM_ :: Async ( WithEarlyExit m) a -> Async ( WithEarlyExit m) b -> STM ( WithEarlyExit m) () Source #

waitEitherCatchSTM :: Async ( WithEarlyExit m) a -> Async ( WithEarlyExit m) b -> STM ( WithEarlyExit m) ( Either ( Either SomeException a) ( Either SomeException b)) Source #

waitBothSTM :: Async ( WithEarlyExit m) a -> Async ( WithEarlyExit m) b -> STM ( WithEarlyExit m) (a, b) Source #

wait :: Async ( WithEarlyExit m) a -> WithEarlyExit m a Source #

poll :: Async ( WithEarlyExit m) a -> WithEarlyExit m ( Maybe ( Either SomeException a)) Source #

waitCatch :: Async ( WithEarlyExit m) a -> WithEarlyExit m ( Either SomeException a) Source #

cancel :: Async ( WithEarlyExit m) a -> WithEarlyExit m () Source #

cancelWith :: Exception e => Async ( WithEarlyExit m) a -> e -> WithEarlyExit m () Source #

uninterruptibleCancel :: Async ( WithEarlyExit m) a -> WithEarlyExit m () Source #

waitAny :: [ Async ( WithEarlyExit m) a] -> WithEarlyExit m ( Async ( WithEarlyExit m) a, a) Source #

waitAnyCatch :: [ Async ( WithEarlyExit m) a] -> WithEarlyExit m ( Async ( WithEarlyExit m) a, Either SomeException a) Source #

waitAnyCancel :: [ Async ( WithEarlyExit m) a] -> WithEarlyExit m ( Async ( WithEarlyExit m) a, a) Source #

waitAnyCatchCancel :: [ Async ( WithEarlyExit m) a] -> WithEarlyExit m ( Async ( WithEarlyExit m) a, Either SomeException a) Source #

waitEither :: Async ( WithEarlyExit m) a -> Async ( WithEarlyExit m) b -> WithEarlyExit m ( Either a b) Source #

waitEitherCatch :: Async ( WithEarlyExit m) a -> Async ( WithEarlyExit m) b -> WithEarlyExit m ( Either ( Either SomeException a) ( Either SomeException b)) Source #

waitEitherCancel :: Async ( WithEarlyExit m) a -> Async ( WithEarlyExit m) b -> WithEarlyExit m ( Either a b) Source #

waitEitherCatchCancel :: Async ( WithEarlyExit m) a -> Async ( WithEarlyExit m) b -> WithEarlyExit m ( Either ( Either SomeException a) ( Either SomeException b)) Source #

waitEither_ :: Async ( WithEarlyExit m) a -> Async ( WithEarlyExit m) b -> WithEarlyExit m () Source #

waitBoth :: Async ( WithEarlyExit m) a -> Async ( WithEarlyExit m) b -> WithEarlyExit m (a, b) Source #

race :: WithEarlyExit m a -> WithEarlyExit m b -> WithEarlyExit m ( Either a b) Source #

race_ :: WithEarlyExit m a -> WithEarlyExit m b -> WithEarlyExit m () Source #

concurrently :: WithEarlyExit m a -> WithEarlyExit m b -> WithEarlyExit m (a, b) Source #

concurrently_ :: WithEarlyExit m a -> WithEarlyExit m b -> WithEarlyExit m () Source #

asyncWithUnmask :: (( forall b. WithEarlyExit m b -> WithEarlyExit m b) -> WithEarlyExit m a) -> WithEarlyExit m ( Async ( WithEarlyExit m) a) Source #

( MonadAsync m, MonadCatch ( STM m)) => MonadAsync ( ReaderT r m)
Instance details

Defined in Control.Monad.Class.MonadAsync

Associated Types

type Async ( ReaderT r m) = (async :: Type -> Type ) Source #

Methods

async :: ReaderT r m a -> ReaderT r m ( Async ( ReaderT r m) a) Source #

asyncThreadId :: Async ( ReaderT r m) a -> ThreadId ( ReaderT r m) Source #

withAsync :: ReaderT r m a -> ( Async ( ReaderT r m) a -> ReaderT r m b) -> ReaderT r m b Source #

waitSTM :: Async ( ReaderT r m) a -> STM ( ReaderT r m) a Source #

pollSTM :: Async ( ReaderT r m) a -> STM ( ReaderT r m) ( Maybe ( Either SomeException a)) Source #

waitCatchSTM :: Async ( ReaderT r m) a -> STM ( ReaderT r m) ( Either SomeException a) Source #

waitAnySTM :: [ Async ( ReaderT r m) a] -> STM ( ReaderT r m) ( Async ( ReaderT r m) a, a) Source #

waitAnyCatchSTM :: [ Async ( ReaderT r m) a] -> STM ( ReaderT r m) ( Async ( ReaderT r m) a, Either SomeException a) Source #

waitEitherSTM :: Async ( ReaderT r m) a -> Async ( ReaderT r m) b -> STM ( ReaderT r m) ( Either a b) Source #

waitEitherSTM_ :: Async ( ReaderT r m) a -> Async ( ReaderT r m) b -> STM ( ReaderT r m) () Source #

waitEitherCatchSTM :: Async ( ReaderT r m) a -> Async ( ReaderT r m) b -> STM ( ReaderT r m) ( Either ( Either SomeException a) ( Either SomeException b)) Source #

waitBothSTM :: Async ( ReaderT r m) a -> Async ( ReaderT r m) b -> STM ( ReaderT r m) (a, b) Source #

wait :: Async ( ReaderT r m) a -> ReaderT r m a Source #

poll :: Async ( ReaderT r m) a -> ReaderT r m ( Maybe ( Either SomeException a)) Source #

waitCatch :: Async ( ReaderT r m) a -> ReaderT r m ( Either SomeException a) Source #

cancel :: Async ( ReaderT r m) a -> ReaderT r m () Source #

cancelWith :: Exception e => Async ( ReaderT r m) a -> e -> ReaderT r m () Source #

uninterruptibleCancel :: Async ( ReaderT r m) a -> ReaderT r m () Source #

waitAny :: [ Async ( ReaderT r m) a] -> ReaderT r m ( Async ( ReaderT r m) a, a) Source #

waitAnyCatch :: [ Async ( ReaderT r m) a] -> ReaderT r m ( Async ( ReaderT r m) a, Either SomeException a) Source #

waitAnyCancel :: [ Async ( ReaderT r m) a] -> ReaderT r m ( Async ( ReaderT r m) a, a) Source #

waitAnyCatchCancel :: [ Async ( ReaderT r m) a] -> ReaderT r m ( Async ( ReaderT r m) a, Either SomeException a) Source #

waitEither :: Async ( ReaderT r m) a -> Async ( ReaderT r m) b -> ReaderT r m ( Either a b) Source #

waitEitherCatch :: Async ( ReaderT r m) a -> Async ( ReaderT r m) b -> ReaderT r m ( Either ( Either SomeException a) ( Either SomeException b)) Source #

waitEitherCancel :: Async ( ReaderT r m) a -> Async ( ReaderT r m) b -> ReaderT r m ( Either a b) Source #

waitEitherCatchCancel :: Async ( ReaderT r m) a -> Async ( ReaderT r m) b -> ReaderT r m ( Either ( Either SomeException a) ( Either SomeException b)) Source #

waitEither_ :: Async ( ReaderT r m) a -> Async ( ReaderT r m) b -> ReaderT r m () Source #

waitBoth :: Async ( ReaderT r m) a -> Async ( ReaderT r m) b -> ReaderT r m (a, b) Source #

race :: ReaderT r m a -> ReaderT r m b -> ReaderT r m ( Either a b) Source #

race_ :: ReaderT r m a -> ReaderT r m b -> ReaderT r m () Source #

concurrently :: ReaderT r m a -> ReaderT r m b -> ReaderT r m (a, b) Source #

concurrently_ :: ReaderT r m a -> ReaderT r m b -> ReaderT r m () Source #

asyncWithUnmask :: (( forall b. ReaderT r m b -> ReaderT r m b) -> ReaderT r m a) -> ReaderT r m ( Async ( ReaderT r m) a) Source #

linkTo :: ( MonadAsync m, MonadFork m, MonadMask m) => ThreadId m -> Async m a -> m () Source #

Generalizion of link that links an async to an arbitrary thread.

MonadST

class Monad m => MonadST (m :: Type -> Type ) where Source #

This class is for abstracting over stToIO which allows running ST actions in IO . In this case it is to allow running ST actions within another monad m .

The type of stToIO is:

stToIO : ST RealWorld a -> IO a

Abstracting over this is tricky because we need to not care about both the IO , and also the RealWorld .

A solution is to write an action that is given the liftST as an argument and where that action itself is polymorphic in the s parameter. This allows us to instantiate it with RealWorld in the IO case, and the local s in a case where we are embedding into another ST action.

Methods

withLiftST :: ( forall s. ( forall a. ST s a -> m a) -> b) -> b Source #

Instances

Instances details
MonadST IO
Instance details

Defined in Control.Monad.Class.MonadST

Methods

withLiftST :: ( forall s. ( forall a. ST s a -> IO a) -> b) -> b Source #

MonadST ( ST s)
Instance details

Defined in Control.Monad.Class.MonadST

Methods

withLiftST :: ( forall s0. ( forall a. ST s0 a -> ST s a) -> b) -> b Source #

MonadST m => MonadST ( WithEarlyExit m) Source #
Instance details

Defined in Ouroboros.Consensus.Util.EarlyExit

Methods

withLiftST :: ( forall s. ( forall a. ST s a -> WithEarlyExit m a) -> b) -> b Source #

MonadST m => MonadST ( ReaderT r m)
Instance details

Defined in Control.Monad.Class.MonadST

Methods

withLiftST :: ( forall s. ( forall a. ST s a -> ReaderT r m a) -> b) -> b Source #

MonadTime

data DiffTime Source #

This is a length of time, as measured by a clock. Conversion functions will treat it as seconds. It has a precision of 10^-12 s.

Instances

Instances details
Enum DiffTime
Instance details

Defined in Data.Time.Clock.Internal.DiffTime

Eq DiffTime
Instance details

Defined in Data.Time.Clock.Internal.DiffTime

Fractional DiffTime
Instance details

Defined in Data.Time.Clock.Internal.DiffTime

Data DiffTime
Instance details

Defined in Data.Time.Clock.Internal.DiffTime

Methods

gfoldl :: ( forall d b. Data d => c (d -> b) -> d -> c b) -> ( forall g. g -> c g) -> DiffTime -> c DiffTime Source #

gunfold :: ( forall b r. Data b => c (b -> r) -> c r) -> ( forall r. r -> c r) -> Constr -> c DiffTime Source #

toConstr :: DiffTime -> Constr Source #

dataTypeOf :: DiffTime -> DataType Source #

dataCast1 :: Typeable t => ( forall d. Data d => c (t d)) -> Maybe (c DiffTime ) Source #

dataCast2 :: Typeable t => ( forall d e. ( Data d, Data e) => c (t d e)) -> Maybe (c DiffTime ) Source #

gmapT :: ( forall b. Data b => b -> b) -> DiffTime -> DiffTime Source #

gmapQl :: (r -> r' -> r) -> r -> ( forall d. Data d => d -> r') -> DiffTime -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> ( forall d. Data d => d -> r') -> DiffTime -> r Source #

gmapQ :: ( forall d. Data d => d -> u) -> DiffTime -> [u] Source #

gmapQi :: Int -> ( forall d. Data d => d -> u) -> DiffTime -> u Source #

gmapM :: Monad m => ( forall d. Data d => d -> m d) -> DiffTime -> m DiffTime Source #

gmapMp :: MonadPlus m => ( forall d. Data d => d -> m d) -> DiffTime -> m DiffTime Source #

gmapMo :: MonadPlus m => ( forall d. Data d => d -> m d) -> DiffTime -> m DiffTime Source #

Num DiffTime
Instance details

Defined in Data.Time.Clock.Internal.DiffTime

Ord DiffTime
Instance details

Defined in Data.Time.Clock.Internal.DiffTime

Real DiffTime
Instance details

Defined in Data.Time.Clock.Internal.DiffTime

RealFrac DiffTime
Instance details

Defined in Data.Time.Clock.Internal.DiffTime

Show DiffTime
Instance details

Defined in Data.Time.Clock.Internal.DiffTime

NFData DiffTime
Instance details

Defined in Data.Time.Clock.Internal.DiffTime

NoThunks DiffTime
Instance details

Defined in NoThunks.Class

class Monad m => MonadMonotonicTime (m :: Type -> Type ) where Source #

Methods

getMonotonicTime :: m Time Source #

Time in a monotonic clock, with high precision. The epoch for this clock is arbitrary and does not correspond to any wall clock or calendar.

newtype Time Source #

A point in time in a monotonic clock.

The epoch for this clock is arbitrary and does not correspond to any wall clock or calendar, and is not guaranteed to be the same epoch across program runs. It is represented as the DiffTime from this arbitrary epoch.

Constructors

Time DiffTime

Instances

Instances details
Eq Time
Instance details

Defined in Control.Monad.Class.MonadTime

Ord Time
Instance details

Defined in Control.Monad.Class.MonadTime

Show Time
Instance details

Defined in Control.Monad.Class.MonadTime

Generic Time
Instance details

Defined in Control.Monad.Class.MonadTime

Associated Types

type Rep Time :: Type -> Type Source #

NoThunks Time Source #
Instance details

Defined in Ouroboros.Consensus.Util.Orphans

Condense Time Source #
Instance details

Defined in Ouroboros.Consensus.Util.Condense

SAct ( SuspendDecision Time ) ( Maybe ( PeerState m))

Action of SuspendDecision on Maybe PeerState . We use this action together with alter function.

Note: SuspendDecision does not act on PeerState , only the sub-semigroup generated by SuspendConsumer and SuspendPeer does.

Instance details

Defined in Ouroboros.Network.Subscription.PeerState

type Rep Time
Instance details

Defined in Control.Monad.Class.MonadTime

type Rep Time = D1 (' MetaData "Time" "Control.Monad.Class.MonadTime" "io-classes-0.2.0.0-Io7mkgM70BO80kViq0zOYI" ' True ) ( C1 (' MetaCons "Time" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 DiffTime )))

addTime :: DiffTime -> Time -> Time infixr 9 Source #

Add a duration to a point in time, giving another time.

diffTime :: Time -> Time -> DiffTime Source #

The time duration between two points in time (positive or negative).

MonadDelay

class Monad m => MonadDelay (m :: Type -> Type ) where Source #

Minimal complete definition

Nothing

MonadEventlog

class Monad m => MonadEventlog (m :: Type -> Type ) where Source #

Methods

traceEventIO :: String -> m () Source #

Emits a message to the eventlog, if eventlog profiling is available and enabled at runtime.

traceMarkerIO :: String -> m () Source #

Emits a marker to the eventlog, if eventlog profiling is available and enabled at runtime.

The String is the name of the marker. The name is just used in the profiling tools to help you keep clear which marker is which.

MonadEvaluate

NoThunks

class NoThunks a where Source #

Check a value for unexpected thunks

Minimal complete definition

Nothing

Methods

noThunks :: Context -> a -> IO ( Maybe ThunkInfo ) Source #

Check if the argument does not contain any unexpected thunks

For most datatypes, we should have that

noThunks ctxt x == Nothing

if and only if

checkContainsThunks x

For some datatypes however, some thunks are expected. For example, the internal fingertree Sequence might contain thunks (this is important for the asymptotic complexity of this data structure). However, we should still check that the values in the sequence don't contain any unexpected thunks.

This means that we need to traverse the sequence, which might force some of the thunks in the tree. In general, it is acceptable for noThunks to force such "expected thunks", as long as it always reports the unexpected thunks.

The default implementation of noThunks checks that the argument is in WHNF, and if so, adds the type into the context (using showTypeOf ), and calls wNoThunks . See ThunkInfo for a detailed discussion of the type context.

See also discussion of caveats listed for checkContainsThunks .

wNoThunks :: Context -> a -> IO ( Maybe ThunkInfo ) Source #

Check that the argument is in normal form, assuming it is in WHNF.

The context will already have been extended with the type we're looking at, so all that's left is to look at the thunks inside the type. The default implementation uses GHC Generics to do this.

showTypeOf :: Proxy a -> String Source #

Show type a (to add to the context)

We try hard to avoid Typeable constraints in this module: there are types with no Typeable instance but with a NoThunks instance (most important example are types such as ST s which rely on parametric polymorphism). By default we should therefore only show the "outer layer"; for example, if we have a type

Seq (ST s ())

then showTypeOf should just give Seq , leaving it up to the instance for ST to decide how to implement showTypeOf ; this keeps things compositional. The default implementation does precisely this using the metadata that GHC Generics provides.

For convenience, however, some of the deriving via newtype wrappers we provide do depend on Typeable ; see below.

Instances

Instances details
NoThunks Bool
Instance details

Defined in NoThunks.Class

NoThunks Char
Instance details

Defined in NoThunks.Class

NoThunks Double
Instance details

Defined in NoThunks.Class

NoThunks Float
Instance details

Defined in NoThunks.Class

NoThunks Int
Instance details

Defined in NoThunks.Class

NoThunks Int8
Instance details

Defined in NoThunks.Class

NoThunks Int16
Instance details

Defined in NoThunks.Class

NoThunks Int32
Instance details

Defined in NoThunks.Class

NoThunks Int64
Instance details

Defined in NoThunks.Class

NoThunks Integer
Instance details

Defined in NoThunks.Class

NoThunks Natural
Instance details

Defined in NoThunks.Class

NoThunks Word
Instance details

Defined in NoThunks.Class

NoThunks Word8
Instance details

Defined in NoThunks.Class

NoThunks Word16
Instance details

Defined in NoThunks.Class

NoThunks Word32
Instance details

Defined in NoThunks.Class

NoThunks Word64
Instance details

Defined in NoThunks.Class

NoThunks CallStack

Since CallStacks can't retain application data, we don't want to check them for thunks at all

Instance details

Defined in NoThunks.Class

NoThunks ()
Instance details

Defined in NoThunks.Class

NoThunks ByteString

Instance for string bytestrings

Strict bytestrings shouldn't contain any thunks, but could, due to https://gitlab.haskell.org/ghc/ghc/issues/17290 . However, such thunks can't retain any data that they shouldn't, and so it's safe to ignore such thunks.

Instance details

Defined in NoThunks.Class

NoThunks ByteString

Instance for lazy bytestrings

Defined manually so that it piggy-backs on the one for strict bytestrings.

Instance details

Defined in NoThunks.Class

NoThunks UTCTime
Instance details

Defined in NoThunks.Class

NoThunks Text
Instance details

Defined in NoThunks.Class

NoThunks Text
Instance details

Defined in NoThunks.Class

NoThunks Void
Instance details

Defined in NoThunks.Class

NoThunks ShortByteString

Instance for short bytestrings

We have

data ShortByteString = SBS ByteArray#

Values of this type consist of a tag followed by an _unboxed_ byte array, which can't contain thunks. Therefore we only check WHNF.

Instance details

Defined in NoThunks.Class

NoThunks Seed
Instance details

Defined in Cardano.Crypto.Seed

NoThunks SystemStart
Instance details

Defined in Cardano.Slotting.Time

NoThunks RelativeTime
Instance details

Defined in Cardano.Slotting.Time

NoThunks SlotLength
Instance details

Defined in Cardano.Slotting.Time

NoThunks SlotNo
Instance details

Defined in Cardano.Slotting.Slot

NoThunks EpochNo
Instance details

Defined in Cardano.Slotting.Slot

NoThunks EpochSize
Instance details

Defined in Cardano.Slotting.Slot

NoThunks BlockNo
Instance details

Defined in Cardano.Slotting.Block

NoThunks DiffTime
Instance details

Defined in NoThunks.Class

NoThunks NominalDiffTime
Instance details

Defined in NoThunks.Class

NoThunks Time Source #
Instance details

Defined in Ouroboros.Consensus.Util.Orphans

NoThunks MaxSlotNo
Instance details

Defined in Ouroboros.Network.Block

NoThunks NetworkMagic
Instance details

Defined in Ouroboros.Network.Magic

NoThunks ZonedTime
Instance details

Defined in NoThunks.Class

NoThunks TimeLocale
Instance details

Defined in NoThunks.Class

NoThunks LocalTime
Instance details

Defined in NoThunks.Class

NoThunks TimeOfDay
Instance details

Defined in NoThunks.Class

NoThunks TimeZone
Instance details

Defined in NoThunks.Class