Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- class (MonadAsync m, MonadLabelledSTM m, MonadTraceSTM m, MonadMVar m, MonadEventlog m, MonadFork m, MonadST m, MonadDelay m, MonadThread m, MonadThrow m, MonadCatch m, MonadMask m, MonadMonotonicTime m, MonadEvaluate m, Alternative (STM m), MonadCatch (STM m), PrimMonad m, ∀ a. NoThunks (m a), ∀ a. NoThunks a ⇒ NoThunks (StrictTVar m a), ∀ a. NoThunks a ⇒ NoThunks (StrictSVar m a), ∀ a. NoThunks a ⇒ NoThunks (StrictMVar m a), ∀ a. NoThunks a ⇒ NoThunks (StrictTVar m a), ∀ a. NoThunks a ⇒ NoThunks (StrictMVar m a)) ⇒ IOLike m where
- forgetSignKeyKES ∷ KESAlgorithm v ⇒ SignKeyKES v → m ()
- class (Typeable e, Show e) ⇒ Exception e where
- toException ∷ e → SomeException
- fromException ∷ SomeException → Maybe e
- displayException ∷ e → String
- data ExitCase a
- class MonadThrow m ⇒ MonadCatch (m ∷ Type → Type) where
- catch ∷ Exception e ⇒ m a → (e → m a) → m a
- catchJust ∷ Exception e ⇒ (e → Maybe b) → m a → (b → m a) → m a
- try ∷ Exception e ⇒ m a → m (Either e a)
- tryJust ∷ Exception e ⇒ (e → Maybe b) → m a → m (Either b a)
- handle ∷ Exception e ⇒ (e → m a) → m a → m a
- handleJust ∷ Exception e ⇒ (e → Maybe b) → (b → m a) → m a → m a
- onException ∷ m a → m b → m a
- bracketOnError ∷ m a → (a → m b) → (a → m c) → m c
- generalBracket ∷ m a → (a → ExitCase b → m c) → (a → m b) → m (b, c)
- class MonadCatch m ⇒ MonadMask (m ∷ Type → Type) where
- mask ∷ ((∀ a. m a → m a) → m b) → m b
- uninterruptibleMask ∷ ((∀ a. m a → m a) → m b) → m b
- mask_ ∷ m a → m a
- uninterruptibleMask_ ∷ m a → m a
- class Monad m ⇒ MonadThrow (m ∷ Type → Type) where
- data SomeException
- module Ouroboros.Consensus.Util.MonadSTM.NormalForm
- module Ouroboros.Consensus.Util.NormalForm.StrictMVar
- module Ouroboros.Consensus.Util.NormalForm.StrictTVar
- class MonadThread m ⇒ MonadFork (m ∷ Type → Type) where
- forkIO ∷ m () → m (ThreadId m)
- forkOn ∷ Int → m () → m (ThreadId m)
- forkIOWithUnmask ∷ ((∀ a. m a → m a) → m ()) → m (ThreadId m)
- forkFinally ∷ m a → (Either SomeException a → m ()) → m (ThreadId m)
- throwTo ∷ Exception e ⇒ ThreadId m → e → m ()
- killThread ∷ ThreadId m → m ()
- yield ∷ m ()
- class (Monad m, Eq (ThreadId m), Ord (ThreadId m), Show (ThreadId m)) ⇒ MonadThread (m ∷ Type → Type) where
- type ThreadId (m ∷ Type → Type)
- myThreadId ∷ m (ThreadId m)
- labelThread ∷ ThreadId m → String → m ()
- labelThisThread ∷ MonadThread m ⇒ String → m ()
- data ExceptionInLinkedThread = ExceptionInLinkedThread String SomeException
- class (MonadSTM m, MonadThread m) ⇒ MonadAsync (m ∷ Type → Type) where
- type Async (m ∷ Type → Type) = (async ∷ Type → Type) | async → m
- async ∷ m a → m (Async m a)
- asyncBound ∷ m a → m (Async m a)
- asyncOn ∷ Int → m a → m (Async m a)
- asyncThreadId ∷ Async m a → ThreadId m
- withAsync ∷ m a → (Async m a → m b) → m b
- withAsyncBound ∷ m a → (Async m a → m b) → m b
- withAsyncOn ∷ Int → m a → (Async m a → m b) → m b
- waitSTM ∷ Async m a → STM m a
- pollSTM ∷ Async m a → STM m (Maybe (Either SomeException a))
- waitCatchSTM ∷ Async m a → STM m (Either SomeException a)
- waitAnySTM ∷ [Async m a] → STM m (Async m a, a)
- waitAnyCatchSTM ∷ [Async m a] → STM m (Async m a, Either SomeException a)
- waitEitherSTM ∷ Async m a → Async m b → STM m (Either a b)
- waitEitherSTM_ ∷ Async m a → Async m b → STM m ()
- waitEitherCatchSTM ∷ Async m a → Async m b → STM m (Either (Either SomeException a) (Either SomeException b))
- waitBothSTM ∷ Async m a → Async m b → STM m (a, b)
- wait ∷ Async m a → m a
- poll ∷ Async m a → m (Maybe (Either SomeException a))
- waitCatch ∷ Async m a → m (Either SomeException a)
- cancel ∷ Async m a → m ()
- cancelWith ∷ Exception e ⇒ Async m a → e → m ()
- uninterruptibleCancel ∷ Async m a → m ()
- waitAny ∷ [Async m a] → m (Async m a, a)
- waitAnyCatch ∷ [Async m a] → m (Async m a, Either SomeException a)
- waitAnyCancel ∷ [Async m a] → m (Async m a, a)
- waitAnyCatchCancel ∷ [Async m a] → m (Async m a, Either SomeException a)
- waitEither ∷ Async m a → Async m b → m (Either a b)
- waitEitherCatch ∷ Async m a → Async m b → m (Either (Either SomeException a) (Either SomeException b))
- waitEitherCancel ∷ Async m a → Async m b → m (Either a b)
- waitEitherCatchCancel ∷ Async m a → Async m b → m (Either (Either SomeException a) (Either SomeException b))
- waitEither_ ∷ Async m a → Async m b → m ()
- waitBoth ∷ Async m a → Async m b → m (a, b)
- race ∷ m a → m b → m (Either a b)
- race_ ∷ m a → m b → m ()
- concurrently ∷ m a → m b → m (a, b)
- concurrently_ ∷ m a → m b → m ()
- asyncWithUnmask ∷ ((∀ b. m b → m b) → m a) → m (Async m a)
- asyncOnWithUnmask ∷ Int → ((∀ b. m b → m b) → m a) → m (Async m a)
- withAsyncWithUnmask ∷ ((∀ c. m c → m c) → m a) → (Async m a → m b) → m b
- withAsyncOnWithUnmask ∷ Int → ((∀ c. m c → m c) → m a) → (Async m a → m b) → m b
- compareAsyncs ∷ Async m a → Async m b → Ordering
- link ∷ (MonadAsync m, MonadFork m, MonadMask m) ⇒ Async m a → m ()
- linkTo ∷ (MonadAsync m, MonadFork m, MonadMask m) ⇒ ThreadId m → Async m a → m ()
- class PrimMonad m ⇒ MonadST (m ∷ Type → Type) where
- stToIO ∷ ST (PrimState m) a → m a
- withLiftST ∷ (∀ s. (∀ a. ST s a → m a) → b) → b
- class Monad m ⇒ PrimMonad (m ∷ Type → Type) where
- data DiffTime
- class MonadMonotonicTimeNSec m ⇒ MonadMonotonicTime (m ∷ Type → Type) where
- getMonotonicTime ∷ m Time
- newtype Time = Time DiffTime
- addTime ∷ DiffTime → Time → Time
- diffTime ∷ Time → Time → DiffTime
- class (MonadDelay m, MonadMonotonicTime m) ⇒ MonadDelay (m ∷ Type → Type) where
- threadDelay ∷ DiffTime → m ()
- class Monad m ⇒ MonadEventlog (m ∷ Type → Type) where
- traceEventIO ∷ String → m ()
- traceMarkerIO ∷ String → m ()
- class MonadThrow m ⇒ MonadEvaluate (m ∷ Type → Type) where
- evaluate ∷ a → m a
- class NoThunks a where
Documentation
class (MonadAsync m, MonadLabelledSTM m, MonadTraceSTM m, MonadMVar m, MonadEventlog m, MonadFork m, MonadST m, MonadDelay m, MonadThread m, MonadThrow m, MonadCatch m, MonadMask m, MonadMonotonicTime m, MonadEvaluate m, Alternative (STM m), MonadCatch (STM m), PrimMonad m, ∀ a. NoThunks (m a), ∀ a. NoThunks a ⇒ NoThunks (StrictTVar m a), ∀ a. NoThunks a ⇒ NoThunks (StrictSVar m a), ∀ a. NoThunks a ⇒ NoThunks (StrictMVar m a), ∀ a. NoThunks a ⇒ NoThunks (StrictTVar m a), ∀ a. NoThunks a ⇒ NoThunks (StrictMVar m a)) ⇒ IOLike m where Source #
forgetSignKeyKES ∷ KESAlgorithm v ⇒ SignKeyKES v → m () Source #
Securely forget a KES signing key.
No-op for the IOSim, but forgetSignKeyKES
for IO.
Instances
IOLike IO Source # | |
Defined in Ouroboros.Consensus.Util.IOLike forgetSignKeyKES ∷ KESAlgorithm v ⇒ SignKeyKES v → IO () Source # | |
(IOLike m, ∀ a. NoThunks (StrictTVar (WithEarlyExit m) a), ∀ a. NoThunks (StrictSVar (WithEarlyExit m) a), ∀ a. NoThunks (StrictMVar (WithEarlyExit m) a)) ⇒ IOLike (WithEarlyExit m) Source # | |
Defined in Ouroboros.Consensus.Util.EarlyExit forgetSignKeyKES ∷ KESAlgorithm v ⇒ SignKeyKES v → WithEarlyExit m () Source # |
Re-exports
MonadThrow
class (Typeable e, Show e) ⇒ Exception e where #
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
Nothing
toException ∷ e → SomeException #
fromException ∷ SomeException → Maybe e #
displayException ∷ e → String #
Render this exception value in a human-friendly manner.
Default implementation:
.show
Since: base-4.8.0.0
Instances
Used in generalBracket
See exceptions
package for discussion and motivation.
class MonadThrow m ⇒ MonadCatch (m ∷ Type → Type) where Source #
Catching exceptions.
Covers standard utilities to respond to exceptions.
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 #
General form of bracket
See http://hackage.haskell.org/package/exceptions-0.10.0/docs/Control-Monad-Catch.html#v:generalBracket for discussion and motivation.
Instances
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.
mask ∷ ((∀ a. m a → m a) → m b) → m b Source #
uninterruptibleMask ∷ ((∀ a. m a → m a) → m b) → m b Source #
uninterruptibleMask_ ∷ m a → m a Source #
Instances
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.
throwIO ∷ Exception e ⇒ e → m a Source #
bracket ∷ m a → (a → m b) → (a → m c) → m c Source #
Instances
data SomeException #
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
.
Instances
Exception SomeException | Since: base-3.0 |
Show SomeException | Since: base-3.0 |
Defined in GHC.Exception.Type showsPrec ∷ Int → SomeException → ShowS # show ∷ SomeException → String # showList ∷ [SomeException] → ShowS # |
Variables with NoThunks invariants
MonadFork, TODO: Should we hide this in favour of MonadAsync?
class MonadThread m ⇒ MonadFork (m ∷ Type → Type) where Source #
forkIO ∷ m () → m (ThreadId m) Source #
forkOn ∷ Int → m () → m (ThreadId m) Source #
forkIOWithUnmask ∷ ((∀ a. m a → m a) → m ()) → m (ThreadId m) Source #
forkFinally ∷ m a → (Either SomeException a → m ()) → m (ThreadId m) Source #
throwTo ∷ Exception e ⇒ ThreadId m → e → m () Source #
killThread ∷ ThreadId m → m () Source #
Instances
class (Monad m, Eq (ThreadId m), Ord (ThreadId m), Show (ThreadId m)) ⇒ MonadThread (m ∷ Type → Type) where Source #
myThreadId ∷ m (ThreadId m) Source #
labelThread ∷ ThreadId m → String → m () Source #
Instances
MonadThread IO | |
MonadThread m ⇒ MonadThread (WithEarlyExit m) Source # | |
Defined in Ouroboros.Consensus.Util.EarlyExit type ThreadId (WithEarlyExit m) Source # myThreadId ∷ WithEarlyExit m (ThreadId (WithEarlyExit m)) Source # labelThread ∷ ThreadId (WithEarlyExit m) → String → WithEarlyExit m () Source # | |
MonadThread m ⇒ MonadThread (ReaderT r m) | |
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
.
Instances
class (MonadSTM m, MonadThread m) ⇒ MonadAsync (m ∷ Type → Type) where Source #
async, asyncBound, asyncOn, asyncThreadId, cancel, cancelWith, asyncWithUnmask, asyncOnWithUnmask, waitCatchSTM, pollSTM
type Async (m ∷ Type → Type) = (async ∷ Type → Type) | async → m Source #
An asynchronous action
See Async
.
async ∷ m a → m (Async m a) Source #
See async
.
asyncBound ∷ m a → m (Async m a) Source #
See asyncBound
.
asyncOn ∷ Int → m a → m (Async m a) Source #
See asyncOn
.
asyncThreadId ∷ Async m a → ThreadId m Source #
See asyncThreadId
.
withAsync ∷ m a → (Async m a → m b) → m b Source #
See withAsync
.
withAsyncBound ∷ m a → (Async m a → m b) → m b Source #
See withAsyncBound
.
withAsyncOn ∷ Int → m a → (Async m a → m b) → m b Source #
See withAsyncOn
.
waitSTM ∷ Async m a → STM m a Source #
See waitSTM
.
pollSTM ∷ Async m a → STM m (Maybe (Either SomeException a)) Source #
See pollSTM
.
waitCatchSTM ∷ Async m a → STM m (Either SomeException a) Source #
See waitCatchSTM
.
waitAnySTM ∷ [Async m a] → STM m (Async m a, a) Source #
See waitAnySTM
.
waitAnyCatchSTM ∷ [Async m a] → STM m (Async m a, Either SomeException a) Source #
See waitAnyCatchSTM
.
waitEitherSTM ∷ Async m a → Async m b → STM m (Either a b) Source #
See waitEitherSTM
.
waitEitherSTM_ ∷ Async m a → Async m b → STM m () Source #
See waitEitherSTM_
.
waitEitherCatchSTM ∷ Async m a → Async m b → STM m (Either (Either SomeException a) (Either SomeException b)) Source #
See waitEitherCatchSTM
.
waitBothSTM ∷ Async m a → Async m b → STM m (a, b) Source #
See waitBothSTM
.
wait ∷ Async m a → m a Source #
See wait
.
poll ∷ Async m a → m (Maybe (Either SomeException a)) Source #
See poll
.
waitCatch ∷ Async m a → m (Either SomeException a) Source #
See waitCatch
.
cancel ∷ Async m a → m () Source #
See cancel
.
cancelWith ∷ Exception e ⇒ Async m a → e → m () Source #
See cancelWith
.
uninterruptibleCancel ∷ Async m a → m () Source #
waitAny ∷ [Async m a] → m (Async m a, a) Source #
See waitAny
.
waitAnyCatch ∷ [Async m a] → m (Async m a, Either SomeException a) Source #
See waitAnyCatch
.
waitAnyCancel ∷ [Async m a] → m (Async m a, a) Source #
See waitAnyCancel
.
waitAnyCatchCancel ∷ [Async m a] → m (Async m a, Either SomeException a) Source #
See waitAnyCatchCancel
.
waitEither ∷ Async m a → Async m b → m (Either a b) Source #
See waitEither
.
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
See waitEitherCatch
.
waitEitherCancel ∷ Async m a → Async m b → m (Either a b) Source #
See waitEitherCancel
.
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 #
See waitEither_
.
waitBoth ∷ Async m a → Async m b → m (a, b) Source #
See waitBoth
.
race ∷ m a → m b → m (Either a b) Source #
See race
.
race_ ∷ m a → m b → m () Source #
See race_
.
concurrently ∷ m a → m b → m (a, b) Source #
See concurrently
.
concurrently_ ∷ m a → m b → m () Source #
See concurrently_
.
asyncWithUnmask ∷ ((∀ b. m b → m b) → m a) → m (Async m a) Source #
See concurrently_
.
asyncOnWithUnmask ∷ Int → ((∀ b. m b → m b) → m a) → m (Async m a) Source #
See asyncOnWithUnmask
.
withAsyncWithUnmask ∷ ((∀ c. m c → m c) → m a) → (Async m a → m b) → m b Source #
See withAsyncWithUnmask
.
withAsyncOnWithUnmask ∷ Int → ((∀ c. m c → m c) → m a) → (Async m a → m b) → m b Source #
compareAsyncs ∷ Async m a → Async m b → Ordering Source #
See compareAsyncs
.
Instances
MonadST
class PrimMonad 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 normal type of stToIO
is:
stToIO :: ST RealWorld a -> IO a
We have two approaches to abstracting over this, a new and an older
(deprecated) method. The new method borrows the primitive
package's
PrimMonad
and PrimState
type family. This gives us:
stToIO :: ST (PrimState m) a -> m a
Which for IO
is exactly the same as above. For ST
it is identity, while
for IOSim
it is
stToIO :: ST s a -> IOSim s a
The older (deprecated) method is tricky because we need to not care about
both the IO
, and also the RealWorld
, and it does so avoiding mentioning
any s
type (which is what the PrimState
type family gives access to).
The 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.
stToIO ∷ ST (PrimState m) a → m a Source #
Since: io-classes-1.4.1.0
withLiftST ∷ (∀ s. (∀ a. ST s a → m a) → b) → b Source #
Deprecated. Use stToIO
instead.
Instances
MonadST IO | |
MonadST (ST s) | |
MonadST m ⇒ MonadST (WithEarlyExit m) Source # | |
Defined in Ouroboros.Consensus.Util.EarlyExit stToIO ∷ ST (PrimState (WithEarlyExit m)) a → WithEarlyExit m a Source # withLiftST ∷ (∀ s. (∀ a. ST s a → WithEarlyExit m a) → b) → b Source # | |
(MonadST m, PrimMonad m) ⇒ MonadST (ReaderT r m) | |
class Monad m ⇒ PrimMonad (m ∷ Type → Type) where Source #
Class of monads which can perform primitive state-transformer actions.
primitive ∷ (State# (PrimState m) → (# State# (PrimState m), a #)) → m a Source #
Execute a primitive operation.
Instances
MonadTime
This is a length of time, as measured by a clock.
Conversion functions such as fromInteger
and realToFrac
will treat it as seconds.
For example, (0.010 :: DiffTime)
corresponds to 10 milliseconds.
It has a precision of one picosecond (= 10^-12 s). Enumeration functions will treat it as picoseconds.
Instances
class MonadMonotonicTimeNSec m ⇒ MonadMonotonicTime (m ∷ Type → Type) where Source #
Nothing
getMonotonicTime ∷ m Time Source #
Instances
MonadMonotonicTime IO | |
Defined in Control.Monad.Class.MonadTime.SI | |
MonadMonotonicTime m ⇒ MonadMonotonicTime (WithEarlyExit m) Source # | |
Defined in Ouroboros.Consensus.Util.EarlyExit | |
MonadMonotonicTime m ⇒ MonadMonotonicTime (ReaderT r m) | |
Defined in Control.Monad.Class.MonadTime.SI getMonotonicTime ∷ ReaderT r m 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.
Instances
Generic Time | |
Show Time | |
NFData Time | |
Defined in Control.Monad.Class.MonadTime.SI | |
Eq Time | |
Ord Time | |
NoThunks Time | |
Condense Time Source # | |
type Rep Time | |
Defined in Control.Monad.Class.MonadTime.SI type Rep Time = D1 ('MetaData "Time" "Control.Monad.Class.MonadTime.SI" "si-timers-1.5.0.0-021a26bda509542e96f625ada4006d8f6e4805005d95ad81bf668f137fcea505" '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 (MonadDelay m, MonadMonotonicTime m) ⇒ MonadDelay (m ∷ Type → Type) where Source #
threadDelay ∷ DiffTime → m () Source #
Instances
MonadDelay IO | Thread delay. This implementation will not over- or underflow. For delay larger than what For delays smaller than `minBound :: Int` seconds, `minBound :: Int` will be used instead. |
Defined in Control.Monad.Class.MonadTimer.SI threadDelay ∷ DiffTime → IO () Source # | |
MonadDelay m ⇒ MonadDelay (WithEarlyExit m) Source # | |
Defined in Ouroboros.Consensus.Util.EarlyExit threadDelay ∷ DiffTime → WithEarlyExit m () Source # | |
MonadDelay m ⇒ MonadDelay (ReaderT r m) | |
Defined in Control.Monad.Class.MonadTimer.SI threadDelay ∷ DiffTime → ReaderT r m () Source # |
MonadEventlog
class Monad m ⇒ MonadEventlog (m ∷ Type → Type) where Source #
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.
Instances
MonadEventlog IO | |
Defined in Control.Monad.Class.MonadEventlog traceEventIO ∷ String → IO () Source # traceMarkerIO ∷ String → IO () Source # | |
MonadEventlog m ⇒ MonadEventlog (WithEarlyExit m) Source # | |
Defined in Ouroboros.Consensus.Util.EarlyExit traceEventIO ∷ String → WithEarlyExit m () Source # traceMarkerIO ∷ String → WithEarlyExit m () Source # | |
MonadEventlog m ⇒ MonadEventlog (ReaderT r m) | |
Defined in Control.Monad.Class.MonadEventlog traceEventIO ∷ String → ReaderT r m () Source # traceMarkerIO ∷ String → ReaderT r m () Source # |
MonadEvaluate
class MonadThrow m ⇒ MonadEvaluate (m ∷ Type → Type) where Source #
Monads which can evaluate
.
Instances
MonadEvaluate IO | |
Defined in Control.Monad.Class.MonadThrow | |
(MonadEvaluate m, MonadCatch m) ⇒ MonadEvaluate (WithEarlyExit m) Source # | |
Defined in Ouroboros.Consensus.Util.EarlyExit evaluate ∷ a → WithEarlyExit m a Source # | |
MonadEvaluate m ⇒ MonadEvaluate (ReaderT r m) | |
Defined in Control.Monad.Class.MonadThrow |
NoThunks
class NoThunks a where Source #
Check a value for unexpected thunks
Nothing
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
or
whereFrom
if available), 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.