-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Type classes for concurrency with STM, ST and timing
--   
--   Type classes for concurrency with STM, ST and timing
@package io-sim-classes
@version 0.2.0.0

module Control.Monad.Class.MonadEventlog
class Monad m => MonadEventlog m

-- | Emits a message to the eventlog, if eventlog profiling is available
--   and enabled at runtime.
traceEventIO :: MonadEventlog m => String -> m ()

-- | Emits a marker to the eventlog, if eventlog profiling is available and
--   enabled at runtime.
--   
--   The <a>String</a> is the name of the marker. The name is just used in
--   the profiling tools to help you keep clear which marker is which.
traceMarkerIO :: MonadEventlog m => String -> m ()

-- | <i>Deprecated: Use traceEventIO</i>
traceEventM :: MonadEventlog m => String -> m ()

-- | <i>Deprecated: Use traceEventIO</i>
traceMarkerM :: MonadEventlog m => String -> m ()
instance Control.Monad.Class.MonadEventlog.MonadEventlog GHC.Types.IO
instance Control.Monad.Class.MonadEventlog.MonadEventlog m => Control.Monad.Class.MonadEventlog.MonadEventlog (Control.Monad.Trans.Reader.ReaderT r m)

module Control.Monad.Class.MonadFork
class (Monad m, Eq (ThreadId m), Ord (ThreadId m), Show (ThreadId m)) => MonadThread m where {
    type family ThreadId m :: Type;
}
myThreadId :: MonadThread m => m (ThreadId m)
labelThread :: MonadThread m => ThreadId m -> String -> m ()
class MonadThread m => MonadFork m
forkIO :: MonadFork m => m () -> m (ThreadId m)
forkIOWithUnmask :: MonadFork m => ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
throwTo :: (MonadFork m, Exception e) => ThreadId m -> e -> m ()
killThread :: MonadFork m => ThreadId m -> m ()

-- | Apply the label to the current thread
labelThisThread :: MonadThread m => String -> m ()

-- | <i>Deprecated: use forkIO</i>
fork :: MonadFork m => m () -> m (ThreadId m)

-- | <i>Deprecated: use forkIO</i>
forkWithUnmask :: MonadFork m => ((forall a. m a -> m a) -> m ()) -> m (ThreadId m)
instance Control.Monad.Class.MonadFork.MonadFork GHC.Types.IO
instance Control.Monad.Class.MonadFork.MonadFork m => Control.Monad.Class.MonadFork.MonadFork (Control.Monad.Trans.Reader.ReaderT e m)
instance Control.Monad.Class.MonadFork.MonadThread GHC.Types.IO
instance Control.Monad.Class.MonadFork.MonadThread m => Control.Monad.Class.MonadFork.MonadThread (Control.Monad.Trans.Reader.ReaderT e m)

module Control.Monad.Class.MonadST

-- | This class is for abstracting over <a>stToIO</a> which allows running
--   <a>ST</a> actions in <a>IO</a>. In this case it is to allow running
--   <a>ST</a> actions within another monad <tt>m</tt>.
--   
--   The type of <a>stToIO</a> is:
--   
--   <pre>
--   stToIO : ST RealWorld a -&gt; IO a
--   </pre>
--   
--   Abstracting over this is tricky because we need to not care about both
--   the <tt>IO</tt>, and also the <tt>RealWorld</tt>.
--   
--   A solution is to write an action that is given the <tt>liftST</tt> as
--   an argument and where that action itself is polymorphic in the
--   <tt>s</tt> parameter. This allows us to instantiate it with
--   <tt>RealWorld</tt> in the <tt>IO</tt> case, and the local <tt>s</tt>
--   in a case where we are embedding into another <tt>ST</tt> action.
class Monad m => MonadST m
withLiftST :: MonadST m => (forall s. (forall a. ST s a -> m a) -> b) -> b
instance Control.Monad.Class.MonadST.MonadST GHC.Types.IO
instance Control.Monad.Class.MonadST.MonadST (GHC.ST.ST s)
instance Control.Monad.Class.MonadST.MonadST m => Control.Monad.Class.MonadST.MonadST (Control.Monad.Trans.Reader.ReaderT r m)

module Control.Monad.Class.MonadSay
class Monad m => MonadSay m
say :: MonadSay m => String -> m ()
instance Control.Monad.Class.MonadSay.MonadSay GHC.Types.IO
instance Control.Monad.Class.MonadSay.MonadSay m => Control.Monad.Class.MonadSay.MonadSay (Control.Monad.Trans.State.Lazy.StateT s m)

module Control.Monad.Class.MonadThrow

-- | Throwing exceptions, and resource handling in the presence of
--   exceptions.
--   
--   Does not include the ability to respond to exceptions.
class Monad m => MonadThrow m
throwIO :: (MonadThrow m, Exception e) => e -> m a
bracket :: MonadThrow m => m a -> (a -> m b) -> (a -> m c) -> m c
bracket_ :: MonadThrow m => m a -> m b -> m c -> m c
finally :: MonadThrow m => m a -> m b -> m a
bracket :: (MonadThrow m, MonadCatch m) => m a -> (a -> m b) -> (a -> m c) -> m c

-- | Catching exceptions.
--   
--   Covers standard utilities to respond to exceptions.
class MonadThrow m => MonadCatch m
catch :: (MonadCatch m, Exception e) => m a -> (e -> m a) -> m a
catchJust :: (MonadCatch m, Exception e) => (e -> Maybe b) -> m a -> (b -> m a) -> m a
try :: (MonadCatch m, Exception e) => m a -> m (Either e a)
tryJust :: (MonadCatch m, Exception e) => (e -> Maybe b) -> m a -> m (Either b a)
handle :: (MonadCatch m, Exception e) => (e -> m a) -> m a -> m a
handleJust :: (MonadCatch m, Exception e) => (e -> Maybe b) -> (b -> m a) -> m a -> m a
onException :: MonadCatch m => m a -> m b -> m a
bracketOnError :: MonadCatch m => m a -> (a -> m b) -> (a -> m c) -> m c

-- | General form of bracket
--   
--   See
--   <a>http://hackage.haskell.org/package/exceptions-0.10.0/docs/Control-Monad-Catch.html#v:generalBracket</a>
--   for discussion and motivation.
generalBracket :: MonadCatch m => m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c)

-- | General form of bracket
--   
--   See
--   <a>http://hackage.haskell.org/package/exceptions-0.10.0/docs/Control-Monad-Catch.html#v:generalBracket</a>
--   for discussion and motivation.
generalBracket :: (MonadCatch m, MonadMask m) => m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c)

-- | Support for safely working in the presence of asynchronous exceptions.
--   
--   This is typically not needed directly as the utilities in
--   <a>MonadThrow</a> and <a>MonadCatch</a> cover most use cases.
class MonadCatch m => MonadMask m
mask :: MonadMask m => ((forall a. m a -> m a) -> m b) -> m b
uninterruptibleMask :: MonadMask m => ((forall a. m a -> m a) -> m b) -> m b
mask_ :: MonadMask m => m a -> m a
uninterruptibleMask_ :: MonadMask m => m a -> m a

-- | Monads which can <a>evaluate</a>.
class MonadThrow m => MonadEvaluate m
evaluate :: MonadEvaluate m => a -> m a

-- | Any type that you wish to throw or catch as an exception must be an
--   instance of the <tt>Exception</tt> class. The simplest case is a new
--   exception type directly below the root:
--   
--   <pre>
--   data MyException = ThisException | ThatException
--       deriving Show
--   
--   instance Exception MyException
--   </pre>
--   
--   The default method definitions in the <tt>Exception</tt> class do what
--   we need in this case. You can now throw and catch
--   <tt>ThisException</tt> and <tt>ThatException</tt> as exceptions:
--   
--   <pre>
--   *Main&gt; throw ThisException `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: MyException))
--   Caught ThisException
--   </pre>
--   
--   In more complicated examples, you may wish to define a whole hierarchy
--   of exceptions:
--   
--   <pre>
--   ---------------------------------------------------------------------
--   -- Make the root exception type for all the exceptions in a compiler
--   
--   data SomeCompilerException = forall e . Exception e =&gt; SomeCompilerException e
--   
--   instance Show SomeCompilerException where
--       show (SomeCompilerException e) = show e
--   
--   instance Exception SomeCompilerException
--   
--   compilerExceptionToException :: Exception e =&gt; e -&gt; SomeException
--   compilerExceptionToException = toException . SomeCompilerException
--   
--   compilerExceptionFromException :: Exception e =&gt; SomeException -&gt; Maybe e
--   compilerExceptionFromException x = do
--       SomeCompilerException a &lt;- fromException x
--       cast a
--   
--   ---------------------------------------------------------------------
--   -- Make a subhierarchy for exceptions in the frontend of the compiler
--   
--   data SomeFrontendException = forall e . Exception e =&gt; SomeFrontendException e
--   
--   instance Show SomeFrontendException where
--       show (SomeFrontendException e) = show e
--   
--   instance Exception SomeFrontendException where
--       toException = compilerExceptionToException
--       fromException = compilerExceptionFromException
--   
--   frontendExceptionToException :: Exception e =&gt; e -&gt; SomeException
--   frontendExceptionToException = toException . SomeFrontendException
--   
--   frontendExceptionFromException :: Exception e =&gt; SomeException -&gt; Maybe e
--   frontendExceptionFromException x = do
--       SomeFrontendException a &lt;- 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
--   </pre>
--   
--   We can now catch a <tt>MismatchedParentheses</tt> exception as
--   <tt>MismatchedParentheses</tt>, <tt>SomeFrontendException</tt> or
--   <tt>SomeCompilerException</tt>, but not other types, e.g.
--   <tt>IOException</tt>:
--   
--   <pre>
--   *Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: MismatchedParentheses))
--   Caught MismatchedParentheses
--   *Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: SomeFrontendException))
--   Caught MismatchedParentheses
--   *Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: SomeCompilerException))
--   Caught MismatchedParentheses
--   *Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: IOException))
--   *** Exception: MismatchedParentheses
--   </pre>
class (Typeable e, Show e) => Exception e
toException :: Exception e => e -> SomeException
fromException :: Exception e => SomeException -> Maybe e

-- | Render this exception value in a human-friendly manner.
--   
--   Default implementation: <tt><a>show</a></tt>.
displayException :: Exception e => e -> String

-- | The <tt>SomeException</tt> type is the root of the exception type
--   hierarchy. When an exception of type <tt>e</tt> is thrown, behind the
--   scenes it is encapsulated in a <tt>SomeException</tt>.
data SomeException

-- | Used in <a>generalBracket</a>
--   
--   See <tt>exceptions</tt> package for discussion and motivation.
data ExitCase a
ExitCaseSuccess :: a -> ExitCase a
ExitCaseException :: SomeException -> ExitCase a
ExitCaseAbort :: ExitCase a

-- | The default handler type for <a>catches</a>, whcih is a generalisation
--   of <a>Handler</a>.
data Handler m a
Handler :: (e -> m a) -> Handler m a

-- | Like <a>catches</a> but for <a>MonadCatch</a> rather than only
--   <a>IO</a>.
catches :: forall m a. MonadCatch m => m a -> [Handler m a] -> m a

-- | <i>Deprecated: Use throwIO</i>
throwM :: (MonadThrow m, Exception e) => e -> m a
instance GHC.Base.Functor Control.Monad.Class.MonadThrow.ExitCase
instance GHC.Show.Show a => GHC.Show.Show (Control.Monad.Class.MonadThrow.ExitCase a)
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Class.MonadThrow.Handler m)
instance Control.Monad.Class.MonadThrow.MonadEvaluate GHC.Types.IO
instance Control.Monad.Class.MonadThrow.MonadEvaluate m => Control.Monad.Class.MonadThrow.MonadEvaluate (Control.Monad.Trans.Reader.ReaderT r m)
instance Control.Monad.Class.MonadThrow.MonadThrow GHC.Types.IO
instance Control.Monad.Class.MonadThrow.MonadCatch GHC.Types.IO
instance Control.Monad.Class.MonadThrow.MonadMask GHC.Types.IO
instance Control.Monad.Class.MonadThrow.MonadThrow GHC.Conc.Sync.STM
instance Control.Monad.Class.MonadThrow.MonadCatch GHC.Conc.Sync.STM
instance Control.Monad.Class.MonadThrow.MonadThrow m => Control.Monad.Class.MonadThrow.MonadThrow (Control.Monad.Trans.Reader.ReaderT r m)
instance Control.Monad.Class.MonadThrow.MonadCatch m => Control.Monad.Class.MonadThrow.MonadCatch (Control.Monad.Trans.Reader.ReaderT r m)
instance Control.Monad.Class.MonadThrow.MonadMask m => Control.Monad.Class.MonadThrow.MonadMask (Control.Monad.Trans.Reader.ReaderT r m)
instance Control.Monad.Class.MonadThrow.MonadCatch m => Control.Monad.Class.MonadThrow.MonadThrow (Control.Monad.Trans.Except.ExceptT e m)
instance Control.Monad.Class.MonadThrow.MonadCatch m => Control.Monad.Class.MonadThrow.MonadCatch (Control.Monad.Trans.Except.ExceptT e m)
instance Control.Monad.Class.MonadThrow.MonadMask m => Control.Monad.Class.MonadThrow.MonadMask (Control.Monad.Trans.Except.ExceptT e m)

module Control.Monad.Class.MonadSTM
class (Monad m, MonadSTMTx (STM m)) => MonadSTM m where {
    type family STM m :: Type -> Type;
}
atomically :: (MonadSTM m, HasCallStack) => STM m a -> m a
newTVarIO :: MonadSTM m => a -> m (TVar m a)
newTMVarIO :: MonadSTM m => a -> m (TMVar m a)
newEmptyTMVarIO :: MonadSTM m => m (TMVar m a)
newTBQueueIO :: MonadSTM m => Natural -> m (TBQueue m a)
class (Monad stm, Alternative stm, MonadPlus stm) => MonadSTMTx stm where {
    type family TVar_ stm :: Type -> Type;
    type family TMVar_ stm :: Type -> Type;
    type family TQueue_ stm :: Type -> Type;
    type family TBQueue_ stm :: Type -> Type;
}
newTVar :: MonadSTMTx stm => a -> stm (TVar_ stm a)
readTVar :: MonadSTMTx stm => TVar_ stm a -> stm a
writeTVar :: MonadSTMTx stm => TVar_ stm a -> a -> stm ()
retry :: MonadSTMTx stm => stm a
orElse :: MonadSTMTx stm => stm a -> stm a -> stm a
modifyTVar :: MonadSTMTx stm => TVar_ stm a -> (a -> a) -> stm ()
modifyTVar' :: MonadSTMTx stm => TVar_ stm a -> (a -> a) -> stm ()

-- | @since io-sim-classes-0.2.0.0
stateTVar :: MonadSTMTx stm => TVar_ stm s -> (s -> (a, s)) -> stm a
check :: MonadSTMTx stm => Bool -> stm ()
newTMVar :: MonadSTMTx stm => a -> stm (TMVar_ stm a)
newEmptyTMVar :: MonadSTMTx stm => stm (TMVar_ stm a)
takeTMVar :: MonadSTMTx stm => TMVar_ stm a -> stm a
tryTakeTMVar :: MonadSTMTx stm => TMVar_ stm a -> stm (Maybe a)
putTMVar :: MonadSTMTx stm => TMVar_ stm a -> a -> stm ()
tryPutTMVar :: MonadSTMTx stm => TMVar_ stm a -> a -> stm Bool
readTMVar :: MonadSTMTx stm => TMVar_ stm a -> stm a
tryReadTMVar :: MonadSTMTx stm => TMVar_ stm a -> stm (Maybe a)
swapTMVar :: MonadSTMTx stm => TMVar_ stm a -> a -> stm a
isEmptyTMVar :: MonadSTMTx stm => TMVar_ stm a -> stm Bool
newTQueue :: MonadSTMTx stm => stm (TQueue_ stm a)
readTQueue :: MonadSTMTx stm => TQueue_ stm a -> stm a
tryReadTQueue :: MonadSTMTx stm => TQueue_ stm a -> stm (Maybe a)
writeTQueue :: MonadSTMTx stm => TQueue_ stm a -> a -> stm ()
isEmptyTQueue :: MonadSTMTx stm => TQueue_ stm a -> stm Bool
newTBQueue :: MonadSTMTx stm => Natural -> stm (TBQueue_ stm a)
readTBQueue :: MonadSTMTx stm => TBQueue_ stm a -> stm a
tryReadTBQueue :: MonadSTMTx stm => TBQueue_ stm a -> stm (Maybe a)
flushTBQueue :: MonadSTMTx stm => TBQueue_ stm a -> stm [a]
writeTBQueue :: MonadSTMTx stm => TBQueue_ stm a -> a -> stm ()

lengthTBQueue :: MonadSTMTx stm => TBQueue_ stm a -> stm Natural
isEmptyTBQueue :: MonadSTMTx stm => TBQueue_ stm a -> stm Bool
isFullTBQueue :: MonadSTMTx stm => TBQueue_ stm a -> stm Bool

-- | <i>Deprecated: Renamed back to <a>TVar</a></i>
type LazyTVar m = TVar m

-- | <i>Deprecated: Renamed back to <a>TMVar</a></i>
type LazyTMVar m = TMVar m
type TVar m = TVar_ (STM m)
type TMVar m = TMVar_ (STM m)
type TQueue m = TQueue_ (STM m)
type TBQueue m = TBQueue_ (STM m)
newtype TMVarDefault m a
TMVar :: TVar m (Maybe a) -> TMVarDefault m a
newTMVarDefault :: MonadSTM m => a -> STM m (TMVarDefault m a)
newTMVarIODefault :: MonadSTM m => a -> m (TMVarDefault m a)
newEmptyTMVarDefault :: MonadSTM m => STM m (TMVarDefault m a)
newEmptyTMVarIODefault :: MonadSTM m => m (TMVarDefault m a)
takeTMVarDefault :: MonadSTM m => TMVarDefault m a -> STM m a
tryTakeTMVarDefault :: MonadSTM m => TMVarDefault m a -> STM m (Maybe a)
putTMVarDefault :: MonadSTM m => TMVarDefault m a -> a -> STM m ()
tryPutTMVarDefault :: MonadSTM m => TMVarDefault m a -> a -> STM m Bool
readTMVarDefault :: MonadSTM m => TMVarDefault m a -> STM m a
tryReadTMVarDefault :: MonadSTM m => TMVarDefault m a -> STM m (Maybe a)
swapTMVarDefault :: MonadSTM m => TMVarDefault m a -> a -> STM m a
isEmptyTMVarDefault :: MonadSTM m => TMVarDefault m a -> STM m Bool
data TQueueDefault m a
TQueue :: !TVar m [a] -> !TVar m [a] -> TQueueDefault m a
newTQueueDefault :: MonadSTM m => STM m (TQueueDefault m a)
readTQueueDefault :: MonadSTM m => TQueueDefault m a -> STM m a
tryReadTQueueDefault :: MonadSTMTx (STM m) => TQueueDefault m a -> STM m (Maybe a)
writeTQueueDefault :: MonadSTM m => TQueueDefault m a -> a -> STM m ()
isEmptyTQueueDefault :: MonadSTMTx (STM m) => TQueueDefault m a -> STM m Bool
data TBQueueDefault m a
TBQueue :: !TVar m Natural -> !TVar m [a] -> !TVar m Natural -> !TVar m [a] -> !Natural -> TBQueueDefault m a
newTBQueueDefault :: MonadSTM m => Natural -> STM m (TBQueueDefault m a)
readTBQueueDefault :: MonadSTM m => TBQueueDefault m a -> STM m a
tryReadTBQueueDefault :: MonadSTMTx (STM m) => TBQueueDefault m a -> STM m (Maybe a)
writeTBQueueDefault :: MonadSTM m => TBQueueDefault m a -> a -> STM m ()
isEmptyTBQueueDefault :: MonadSTM m => TBQueueDefault m a -> STM m Bool
isFullTBQueueDefault :: MonadSTM m => TBQueueDefault m a -> STM m Bool
lengthTBQueueDefault :: MonadSTM m => TBQueueDefault m a -> STM m Natural
flushTBQueueDefault :: MonadSTM m => TBQueueDefault m a -> STM m [a]

-- | <a>throwIO</a> specialised to <tt>stm</tt> monad.
throwSTM :: (MonadSTMTx stm, MonadThrow stm, Exception e) => e -> stm a

-- | <a>catch</a> speclialized for an <tt>stm</tt> monad.
catchSTM :: (MonadSTMTx stm, MonadCatch stm, Exception e) => stm a -> (e -> stm a) -> stm a

-- | <i>Deprecated: Use newTVarIO</i>
newTVarM :: MonadSTM m => a -> m (TVar m a)

-- | <i>Deprecated: Use newTMVarIO</i>
newTMVarM :: MonadSTM m => a -> m (TMVar m a)

-- | <i>Deprecated: Use newTMVarIODefault</i>
newTMVarMDefault :: MonadSTM m => a -> m (TMVarDefault m a)

-- | <i>Deprecated: Use newEmptyTMVarIO</i>
newEmptyTMVarM :: MonadSTM m => m (TMVar m a)

-- | <i>Deprecated: Use newEmptyTMVarIODefault</i>
newEmptyTMVarMDefault :: MonadSTM m => m (TMVarDefault m a)
instance GHC.Show.Show Control.Monad.Class.MonadSTM.BlockedIndefinitely
instance GHC.Exception.Type.Exception Control.Monad.Class.MonadSTM.BlockedIndefinitely
instance Control.Monad.Class.MonadSTM.MonadSTM GHC.Types.IO
instance Control.Monad.Class.MonadSTM.MonadSTM m => Control.Monad.Class.MonadSTM.MonadSTM (Control.Monad.Trans.Reader.ReaderT r m)
instance Control.Monad.Class.MonadSTM.MonadSTMTx GHC.Conc.Sync.STM

module Control.Monad.Class.MonadSTM.Strict
data TBQueueDefault m a
TBQueue :: !TVar m Natural -> !TVar m [a] -> !TVar m Natural -> !TVar m [a] -> !Natural -> TBQueueDefault m a
data TQueueDefault m a
TQueue :: !TVar m [a] -> !TVar m [a] -> TQueueDefault m a
data TMVarDefault m a
class (Monad m, MonadSTMTx (STM m)) => MonadSTM m where {
    type family STM m :: Type -> Type;
}
atomically :: (MonadSTM m, HasCallStack) => STM m a -> m a
newTBQueueIO :: MonadSTM m => Natural -> m (TBQueue m a)
type TBQueue m = TBQueue_ (STM m)
type TQueue m = TQueue_ (STM m)
class (Monad stm, Alternative stm, MonadPlus stm) => MonadSTMTx stm where {
    type family TVar_ stm :: Type -> Type;
    type family TMVar_ stm :: Type -> Type;
    type family TQueue_ stm :: Type -> Type;
    type family TBQueue_ stm :: Type -> Type;
}
retry :: MonadSTMTx stm => stm a
orElse :: MonadSTMTx stm => stm a -> stm a -> stm a
modifyTVar' :: MonadSTMTx stm => TVar_ stm a -> (a -> a) -> stm ()
check :: MonadSTMTx stm => Bool -> stm ()
newTQueue :: MonadSTMTx stm => stm (TQueue_ stm a)
readTQueue :: MonadSTMTx stm => TQueue_ stm a -> stm a
tryReadTQueue :: MonadSTMTx stm => TQueue_ stm a -> stm (Maybe a)
writeTQueue :: MonadSTMTx stm => TQueue_ stm a -> a -> stm ()
isEmptyTQueue :: MonadSTMTx stm => TQueue_ stm a -> stm Bool
newTBQueue :: MonadSTMTx stm => Natural -> stm (TBQueue_ stm a)
readTBQueue :: MonadSTMTx stm => TBQueue_ stm a -> stm a
tryReadTBQueue :: MonadSTMTx stm => TBQueue_ stm a -> stm (Maybe a)
flushTBQueue :: MonadSTMTx stm => TBQueue_ stm a -> stm [a]
writeTBQueue :: MonadSTMTx stm => TBQueue_ stm a -> a -> stm ()

lengthTBQueue :: MonadSTMTx stm => TBQueue_ stm a -> stm Natural
isEmptyTBQueue :: MonadSTMTx stm => TBQueue_ stm a -> stm Bool
isFullTBQueue :: MonadSTMTx stm => TBQueue_ stm a -> stm Bool
newTMVarDefault :: MonadSTM m => a -> STM m (TMVarDefault m a)
newTMVarIODefault :: MonadSTM m => a -> m (TMVarDefault m a)

-- | <i>Deprecated: Use newTMVarIODefault</i>
newTMVarMDefault :: MonadSTM m => a -> m (TMVarDefault m a)
newEmptyTMVarDefault :: MonadSTM m => STM m (TMVarDefault m a)
newEmptyTMVarIODefault :: MonadSTM m => m (TMVarDefault m a)

-- | <i>Deprecated: Use newEmptyTMVarIODefault</i>
newEmptyTMVarMDefault :: MonadSTM m => m (TMVarDefault m a)
takeTMVarDefault :: MonadSTM m => TMVarDefault m a -> STM m a
tryTakeTMVarDefault :: MonadSTM m => TMVarDefault m a -> STM m (Maybe a)
putTMVarDefault :: MonadSTM m => TMVarDefault m a -> a -> STM m ()
tryPutTMVarDefault :: MonadSTM m => TMVarDefault m a -> a -> STM m Bool
readTMVarDefault :: MonadSTM m => TMVarDefault m a -> STM m a
tryReadTMVarDefault :: MonadSTM m => TMVarDefault m a -> STM m (Maybe a)
swapTMVarDefault :: MonadSTM m => TMVarDefault m a -> a -> STM m a
isEmptyTMVarDefault :: MonadSTM m => TMVarDefault m a -> STM m Bool
newTQueueDefault :: MonadSTM m => STM m (TQueueDefault m a)
writeTQueueDefault :: MonadSTM m => TQueueDefault m a -> a -> STM m ()
readTQueueDefault :: MonadSTM m => TQueueDefault m a -> STM m a
tryReadTQueueDefault :: MonadSTMTx (STM m) => TQueueDefault m a -> STM m (Maybe a)
isEmptyTQueueDefault :: MonadSTMTx (STM m) => TQueueDefault m a -> STM m Bool
newTBQueueDefault :: MonadSTM m => Natural -> STM m (TBQueueDefault m a)
readTBQueueDefault :: MonadSTM m => TBQueueDefault m a -> STM m a
tryReadTBQueueDefault :: MonadSTMTx (STM m) => TBQueueDefault m a -> STM m (Maybe a)
writeTBQueueDefault :: MonadSTM m => TBQueueDefault m a -> a -> STM m ()
isEmptyTBQueueDefault :: MonadSTM m => TBQueueDefault m a -> STM m Bool
isFullTBQueueDefault :: MonadSTM m => TBQueueDefault m a -> STM m Bool
lengthTBQueueDefault :: MonadSTM m => TBQueueDefault m a -> STM m Natural
flushTBQueueDefault :: MonadSTM m => TBQueueDefault m a -> STM m [a]

-- | <a>throwIO</a> specialised to <tt>stm</tt> monad.
throwSTM :: (MonadSTMTx stm, MonadThrow stm, Exception e) => e -> stm a

-- | <a>catch</a> speclialized for an <tt>stm</tt> monad.
catchSTM :: (MonadSTMTx stm, MonadCatch stm, Exception e) => stm a -> (e -> stm a) -> stm a
type LazyTVar m = TVar m
type LazyTMVar m = TMVar m
data StrictTVar m a
castStrictTVar :: LazyTVar m ~ LazyTVar n => StrictTVar m a -> StrictTVar n a

-- | Get the underlying <tt>TVar</tt>
--   
--   Since we obviously cannot guarantee that updates to this
--   <a>LazyTVar</a> will be strict, this should be used with caution.
toLazyTVar :: StrictTVar m a -> LazyTVar m a
newTVar :: MonadSTM m => a -> STM m (StrictTVar m a)
newTVarIO :: MonadSTM m => a -> m (StrictTVar m a)
newTVarWithInvariantIO :: (MonadSTM m, HasCallStack) => (a -> Maybe String) -> a -> m (StrictTVar m a)
readTVar :: MonadSTM m => StrictTVar m a -> STM m a
writeTVar :: (MonadSTM m, HasCallStack) => StrictTVar m a -> a -> STM m ()
modifyTVar :: MonadSTM m => StrictTVar m a -> (a -> a) -> STM m ()
stateTVar :: MonadSTM m => StrictTVar m a -> (a -> (a, b)) -> STM m b
data StrictTMVar m a
castStrictTMVar :: LazyTMVar m ~ LazyTMVar n => StrictTMVar m a -> StrictTMVar n a
newTMVar :: MonadSTM m => a -> STM m (StrictTMVar m a)
newTMVarIO :: MonadSTM m => a -> m (StrictTMVar m a)
newEmptyTMVarIO :: MonadSTM m => m (StrictTMVar m a)
newEmptyTMVar :: MonadSTM m => STM m (StrictTMVar m a)
takeTMVar :: MonadSTM m => StrictTMVar m a -> STM m a
tryTakeTMVar :: MonadSTM m => StrictTMVar m a -> STM m (Maybe a)
putTMVar :: MonadSTM m => StrictTMVar m a -> a -> STM m ()
tryPutTMVar :: MonadSTM m => StrictTMVar m a -> a -> STM m Bool
readTMVar :: MonadSTM m => StrictTMVar m a -> STM m a
tryReadTMVar :: MonadSTM m => StrictTMVar m a -> STM m (Maybe a)
swapTMVar :: MonadSTM m => StrictTMVar m a -> a -> STM m a
isEmptyTMVar :: MonadSTM m => StrictTMVar m a -> STM m Bool

-- | Check invariant (if enabled) before continuing
--   
--   <tt>checkInvariant mErr x</tt> is equal to <tt>x</tt> if <tt>mErr ==
--   Nothing</tt>, and throws an error <tt>err</tt> if <tt>mErr == Just
--   err</tt>.
--   
--   This is exported so that other code that wants to conditionally check
--   invariants can reuse the same logic, rather than having to introduce
--   new per-package flags.
checkInvariant :: HasCallStack => Maybe String -> a -> a

-- | <i>Deprecated: Use stateTVar</i>
updateTVar :: MonadSTM m => StrictTVar m a -> (a -> (a, b)) -> STM m b

-- | <i>Deprecated: Use newTVarIO</i>
newTVarM :: MonadSTM m => a -> m (StrictTVar m a)

-- | <i>Deprecated: Use newTVarWithInvariantIO</i>
newTVarWithInvariantM :: (MonadSTM m, HasCallStack) => (a -> Maybe String) -> a -> m (StrictTVar m a)

-- | <i>Deprecated: Use newTVarIO</i>
newTMVarM :: MonadSTM m => a -> m (StrictTMVar m a)

-- | <i>Deprecated: Use newEmptyTMVarIO</i>
newEmptyTMVarM :: MonadSTM m => m (StrictTMVar m a)

module Control.Monad.Class.MonadTime
class MonadMonotonicTime m => MonadTime m

-- | Wall clock time.
getCurrentTime :: MonadTime m => m UTCTime
class Monad m => MonadMonotonicTime m

-- | 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.
getMonotonicTime :: MonadMonotonicTime m => m Time

-- | 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 <i>not guaranteed</i> to be the same
--   epoch across program runs. It is represented as the <a>DiffTime</a>
--   from this arbitrary epoch.
newtype Time
Time :: DiffTime -> Time

-- | The time duration between two points in time (positive or negative).
diffTime :: Time -> Time -> DiffTime

-- | Add a duration to a point in time, giving another time.
addTime :: DiffTime -> Time -> Time

-- | 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.
data DiffTime

-- | This is the simplest representation of UTC. It consists of the day
--   number, and a time offset from midnight. Note that if a day has a leap
--   second added to it, it will have 86401 seconds.
data UTCTime

-- | diffUTCTime a b = a - b
diffUTCTime :: UTCTime -> UTCTime -> NominalDiffTime

-- | addUTCTime a b = a + b
addUTCTime :: NominalDiffTime -> UTCTime -> UTCTime

-- | This is a length of time, as measured by UTC. It has a precision of
--   10^-12 s.
--   
--   Conversion functions will treat it as seconds. For example, <tt>(0.010
--   :: NominalDiffTime)</tt> corresponds to 10 milliseconds.
--   
--   It ignores leap-seconds, so it's not necessarily a fixed amount of
--   clock time. For instance, 23:00 UTC + 2 hours of NominalDiffTime =
--   01:00 UTC (+ 1 day), regardless of whether a leap-second intervened.
data NominalDiffTime
instance GHC.Show.Show Control.Monad.Class.MonadTime.Time
instance GHC.Classes.Ord Control.Monad.Class.MonadTime.Time
instance GHC.Classes.Eq Control.Monad.Class.MonadTime.Time
instance Control.Monad.Class.MonadTime.MonadTime GHC.Types.IO
instance Control.Monad.Class.MonadTime.MonadTime m => Control.Monad.Class.MonadTime.MonadTime (Control.Monad.Trans.Reader.ReaderT r m)
instance Control.Monad.Class.MonadTime.MonadMonotonicTime GHC.Types.IO
instance Control.Monad.Class.MonadTime.MonadMonotonicTime m => Control.Monad.Class.MonadTime.MonadMonotonicTime (Control.Monad.Trans.Reader.ReaderT r m)

module Control.Monad.Class.MonadTimer
class Monad m => MonadDelay m
threadDelay :: MonadDelay m => DiffTime -> m ()
threadDelay :: (MonadDelay m, MonadTimer m) => DiffTime -> m ()
class (MonadSTM m, MonadDelay m) => MonadTimer m where {
    data family Timeout m :: Type;
}

-- | Create a new timeout which will fire at the given time duration in the
--   future.
--   
--   The timeout will start in the <a>TimeoutPending</a> state and either
--   fire at or after the given time leaving it in the <a>TimeoutFired</a>
--   state, or it may be cancelled with <a>cancelTimeout</a>, leaving it in
--   the <a>TimeoutCancelled</a> state.
--   
--   Timeouts <i>cannot</i> be reset to the pending state once fired or
--   cancelled (as this would be very racy). You should create a new
--   timeout if you need this functionality.
newTimeout :: MonadTimer m => DiffTime -> m (Timeout m)

-- | Read the current state of a timeout. This does not block, but returns
--   the current state. It is your responsibility to use <a>retry</a> to
--   wait.
--   
--   Alternatively you may wish to use the convenience utility
--   <a>awaitTimeout</a> to wait for just the fired or cancelled outcomes.
--   
--   You should consider the cancelled state if you plan to use
--   <a>cancelTimeout</a>.
readTimeout :: MonadTimer m => Timeout m -> STM m TimeoutState
updateTimeout :: MonadTimer m => Timeout m -> DiffTime -> m ()

-- | Cancel a timeout (unless it has already fired), putting it into the
--   <a>TimeoutCancelled</a> state. Code reading and acting on the timeout
--   state need to handle such cancellation appropriately.
--   
--   It is safe to race this concurrently against the timer firing. It will
--   have no effect if the timer fires first.
cancelTimeout :: MonadTimer m => Timeout m -> m ()

-- | Returns <tt>True</tt> when the timeout is fired, or <tt>False</tt> if
--   it is cancelled.
awaitTimeout :: MonadTimer m => Timeout m -> STM m Bool
registerDelay :: MonadTimer m => DiffTime -> m (TVar m Bool)
registerDelay :: (MonadTimer m, MonadFork m) => DiffTime -> m (TVar m Bool)
timeout :: MonadTimer m => DiffTime -> m a -> m (Maybe a)
data TimeoutState
TimeoutPending :: TimeoutState
TimeoutFired :: TimeoutState
TimeoutCancelled :: TimeoutState

-- | 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.
data DiffTime
diffTimeToMicrosecondsAsInt :: DiffTime -> Int
microsecondsAsIntToDiffTime :: Int -> DiffTime
instance Control.Monad.Class.MonadTimer.MonadDelay GHC.Types.IO
instance Control.Monad.Class.MonadTimer.MonadTimer GHC.Types.IO
instance Control.Monad.Class.MonadTimer.MonadDelay m => Control.Monad.Class.MonadTimer.MonadDelay (Control.Monad.Trans.Reader.ReaderT r m)
instance (Control.Monad.Class.MonadTimer.MonadTimer m, Control.Monad.Class.MonadFork.MonadFork m) => Control.Monad.Class.MonadTimer.MonadTimer (Control.Monad.Trans.Reader.ReaderT r m)

module Control.Monad.Class.MonadAsync
class (MonadSTM m, MonadThread m, MonadAsyncSTM (Async m) (STM m)) => MonadAsync m where {
    
    -- | An asynchronous action
    type family Async m :: Type -> Type;
}
async :: MonadAsync m => m a -> m (Async m a)
asyncThreadId :: MonadAsync m => Proxy m -> Async m a -> ThreadId m
withAsync :: MonadAsync m => m a -> (Async m a -> m b) -> m b
wait :: MonadAsync m => Async m a -> m a
poll :: MonadAsync m => Async m a -> m (Maybe (Either SomeException a))
waitCatch :: MonadAsync m => Async m a -> m (Either SomeException a)
cancel :: MonadAsync m => Async m a -> m ()
cancelWith :: (MonadAsync m, Exception e) => Async m a -> e -> m ()
uninterruptibleCancel :: MonadAsync m => Async m a -> m ()
waitAny :: MonadAsync m => [Async m a] -> m (Async m a, a)
waitAnyCatch :: MonadAsync m => [Async m a] -> m (Async m a, Either SomeException a)
waitAnyCancel :: MonadAsync m => [Async m a] -> m (Async m a, a)
waitAnyCatchCancel :: MonadAsync m => [Async m a] -> m (Async m a, Either SomeException a)
waitEither :: MonadAsync m => Async m a -> Async m b -> m (Either a b)

-- | Note, IO-based implementations should override the default
--   implementation. See the <tt>async</tt> package implementation and
--   comments.
--   <a>http://hackage.haskell.org/package/async-2.2.1/docs/src/Control.Concurrent.Async.html#waitEitherCatch</a>
waitEitherCatch :: MonadAsync m => Async m a -> Async m b -> m (Either (Either SomeException a) (Either SomeException b))
waitEitherCancel :: MonadAsync m => Async m a -> Async m b -> m (Either a b)
waitEitherCatchCancel :: MonadAsync m => Async m a -> Async m b -> m (Either (Either SomeException a) (Either SomeException b))
waitEither_ :: MonadAsync m => Async m a -> Async m b -> m ()
waitBoth :: MonadAsync m => Async m a -> Async m b -> m (a, b)
race :: MonadAsync m => m a -> m b -> m (Either a b)
race_ :: MonadAsync m => m a -> m b -> m ()
concurrently :: MonadAsync m => m a -> m b -> m (a, b)
concurrently_ :: MonadAsync m => m a -> m b -> m ()
asyncWithUnmask :: MonadAsync m => ((forall b. m b -> m b) -> m a) -> m (Async m a)
withAsync :: (MonadAsync m, MonadMask m) => m a -> (Async m a -> m b) -> m b
uninterruptibleCancel :: (MonadAsync m, MonadMask m) => Async m a -> m ()
waitAnyCancel :: (MonadAsync m, MonadThrow m) => [Async m a] -> m (Async m a, a)
waitAnyCatchCancel :: (MonadAsync m, MonadThrow m) => [Async m a] -> m (Async m a, Either SomeException a)
waitEitherCancel :: (MonadAsync m, MonadThrow m) => Async m a -> Async m b -> m (Either a b)
waitEitherCatchCancel :: (MonadAsync m, MonadThrow m) => Async m a -> Async m b -> m (Either (Either SomeException a) (Either SomeException b))
class (Functor async, MonadSTMTx stm) => MonadAsyncSTM async stm
waitSTM :: MonadAsyncSTM async stm => async a -> stm a
pollSTM :: MonadAsyncSTM async stm => async a -> stm (Maybe (Either SomeException a))
waitCatchSTM :: MonadAsyncSTM async stm => async a -> stm (Either SomeException a)
waitSTM :: (MonadAsyncSTM async stm, MonadThrow stm) => async a -> stm a
waitAnySTM :: MonadAsyncSTM async stm => [async a] -> stm (async a, a)
waitAnyCatchSTM :: MonadAsyncSTM async stm => [async a] -> stm (async a, Either SomeException a)
waitEitherSTM :: MonadAsyncSTM async stm => async a -> async b -> stm (Either a b)
waitEitherSTM_ :: MonadAsyncSTM async stm => async a -> async b -> stm ()
waitEitherCatchSTM :: MonadAsyncSTM async stm => async a -> async b -> stm (Either (Either SomeException a) (Either SomeException b))
waitBothSTM :: MonadAsyncSTM async stm => async a -> async b -> stm (a, b)
waitAnySTM :: (MonadAsyncSTM async stm, MonadThrow stm) => [async a] -> stm (async a, a)
waitEitherSTM :: (MonadAsyncSTM async stm, MonadThrow stm) => async a -> async b -> stm (Either a b)
waitEitherSTM_ :: (MonadAsyncSTM async stm, MonadThrow stm) => async a -> async b -> stm ()
waitBothSTM :: (MonadAsyncSTM async stm, MonadThrow stm) => async a -> async b -> stm (a, b)

-- | The exception thrown by <a>cancel</a> to terminate a thread.
data AsyncCancelled
AsyncCancelled :: AsyncCancelled

-- | Exception from child thread re-raised in parent thread
--   
--   We record the thread ID of the child thread as a <a>String</a>. This
--   avoids an <tt>m</tt> parameter in the type, which is important:
--   <a>ExceptionInLinkedThread</a> must be an instance of
--   <a>Exception</a>, requiring it to be <tt>Typeable</tt>; if <tt>m</tt>
--   appeared in the type, we would require <tt>m</tt> to be
--   <tt>Typeable</tt>, which does not work with with the simulator, as it
--   would require a <tt>Typeable</tt> constraint on the <tt>s</tt>
--   parameter of <tt>IOSim</tt>.
data ExceptionInLinkedThread
ExceptionInLinkedThread :: String -> SomeException -> ExceptionInLinkedThread
link :: (MonadAsync m, MonadFork m, MonadMask m) => Async m a -> m ()

-- | Generalizion of <a>link</a> that links an async to an arbitrary
--   thread.
linkTo :: (MonadAsync m, MonadFork m, MonadMask m) => ThreadId m -> Async m a -> m ()
linkOnly :: forall m a. (MonadAsync m, MonadFork m, MonadMask m) => (SomeException -> Bool) -> Async m a -> m ()
linkToOnly :: forall m a. (MonadAsync m, MonadFork m, MonadMask m) => ThreadId m -> (SomeException -> Bool) -> Async m a -> m ()
mapConcurrently :: (Traversable t, MonadAsync m) => (a -> m b) -> t a -> m (t b)
forConcurrently :: (Traversable t, MonadAsync m) => t a -> (a -> m b) -> m (t b)
mapConcurrently_ :: (Foldable f, MonadAsync m) => (a -> m b) -> f a -> m ()
forConcurrently_ :: (Foldable f, MonadAsync m) => f a -> (a -> m b) -> m ()
replicateConcurrently :: MonadAsync m => Int -> m a -> m [a]
replicateConcurrently_ :: MonadAsync m => Int -> m a -> m ()

-- | Similar to <a>Concurrently</a> but which works for any
--   <a>MonadAsync</a> instance.
newtype Concurrently m a
Concurrently :: m a -> Concurrently m a
[runConcurrently] :: Concurrently m a -> m a
instance GHC.Show.Show Control.Monad.Class.MonadAsync.ExceptionInLinkedThread
instance GHC.Exception.Type.Exception Control.Monad.Class.MonadAsync.ExceptionInLinkedThread
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Class.MonadAsync.Concurrently m)
instance (GHC.Base.Applicative m, Control.Monad.Class.MonadAsync.MonadAsync m) => GHC.Base.Applicative (Control.Monad.Class.MonadAsync.Concurrently m)
instance (GHC.Base.Alternative m, Control.Monad.Class.MonadAsync.MonadAsync m, Control.Monad.Class.MonadTimer.MonadTimer m) => GHC.Base.Alternative (Control.Monad.Class.MonadAsync.Concurrently m)
instance (GHC.Base.Semigroup a, Control.Monad.Class.MonadAsync.MonadAsync m) => GHC.Base.Semigroup (Control.Monad.Class.MonadAsync.Concurrently m a)
instance (GHC.Base.Monoid a, Control.Monad.Class.MonadAsync.MonadAsync m) => GHC.Base.Monoid (Control.Monad.Class.MonadAsync.Concurrently m a)
instance Control.Monad.Class.MonadAsync.MonadAsync GHC.Types.IO
instance Control.Monad.Class.MonadAsync.MonadAsync m => Control.Monad.Class.MonadAsync.MonadAsync (Control.Monad.Trans.Reader.ReaderT r m)
instance Control.Monad.Class.MonadAsync.MonadAsyncSTM Control.Concurrent.Async.Async GHC.Conc.Sync.STM
