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


-- | The MonadUnliftIO typeclass for unlifting monads to IO (batteries included)
--   
--   Please see the README.md file for details.
@package unliftio
@version 0.1.1.0


-- | Unlifted <a>System.Timeout</a>.
module UnliftIO.Timeout

-- | Unlifted <a>timeout</a>.
timeout :: MonadUnliftIO m => Int -> m a -> m (Maybe a)


-- | Unlifted <a>Control.Concurrent.MVar</a>.
module UnliftIO.MVar

-- | An <a>MVar</a> (pronounced "em-var") is a synchronising variable, used
--   for communication between concurrent threads. It can be thought of as
--   a a box, which may be empty or full.
data MVar a :: * -> *

-- | Lifted <a>newEmptyMVar</a>.
newEmptyMVar :: MonadIO m => m (MVar a)

-- | Lifted <a>newMVar</a>.
newMVar :: MonadIO m => a -> m (MVar a)

-- | Lifted <a>takeMVar</a>.
takeMVar :: MonadIO m => MVar a -> m a

-- | Lifted <a>putMVar</a>.
putMVar :: MonadIO m => MVar a -> a -> m ()

-- | Lifted <a>readMVar</a>.
readMVar :: MonadIO m => MVar a -> m a

-- | Lifted <a>swapMVar</a>.
swapMVar :: MonadIO m => MVar a -> a -> m a

-- | Lifted <a>tryTakeMVar</a>.
tryTakeMVar :: MonadIO m => MVar a -> m (Maybe a)

-- | Lifted <a>tryPutMVar</a>.
tryPutMVar :: MonadIO m => MVar a -> a -> m Bool

-- | Lifted <a>isEmptyMVar</a>.
isEmptyMVar :: MonadIO m => MVar a -> m Bool

-- | Unlifted <a>withMVar</a>.
withMVar :: MonadUnliftIO m => MVar a -> (a -> m b) -> m b

-- | Unlifted <a>withMVarMasked</a>.
withMVarMasked :: MonadUnliftIO m => MVar a -> (a -> m b) -> m b

-- | Unlifted <a>modifyMVar</a>.
modifyMVar :: MonadUnliftIO m => MVar a -> (a -> m (a, b)) -> m b

-- | Unlifted <a>modifyMVar_</a>.
modifyMVar_ :: MonadUnliftIO m => MVar a -> (a -> m a) -> m ()

-- | Unlifted <a>modifyMVarMasked</a>.
modifyMVarMasked :: MonadUnliftIO m => MVar a -> (a -> m (a, b)) -> m b

-- | Unlifted <a>modifyMVarMasked_</a>.
modifyMVarMasked_ :: MonadUnliftIO m => MVar a -> (a -> m a) -> m ()

-- | Lifted <a>tryReadMVar</a>.
tryReadMVar :: MonadIO m => MVar a -> m (Maybe a)

-- | Unlifted <a>mkWeakMVar</a>.
mkWeakMVar :: MonadUnliftIO m => MVar a -> m () -> m (Weak (MVar a))


-- | Orphans instances.
module UnliftIO.Instances
instance Control.Monad.IO.Unlift.MonadUnliftIO m => Control.Monad.IO.Unlift.MonadUnliftIO (Control.Monad.Logger.LoggingT m)
instance Control.Monad.IO.Unlift.MonadUnliftIO m => Control.Monad.IO.Unlift.MonadUnliftIO (Control.Monad.Logger.NoLoggingT m)
instance Control.Monad.IO.Unlift.MonadUnliftIO m => Control.Monad.IO.Unlift.MonadUnliftIO (Control.Monad.Trans.Resource.Internal.ResourceT m)


-- | Unlifted <a>Control.Monad.Trans.Resource</a>.
module UnliftIO.Resource

-- | The Resource transformer. This transformer keeps track of all
--   registered actions, and calls them upon exit (via
--   <tt>runResourceT</tt>). Actions may be registered via
--   <tt>register</tt>, or resources may be allocated atomically via
--   <tt>allocate</tt>. <tt>allocate</tt> corresponds closely to
--   <tt>bracket</tt>.
--   
--   Releasing may be performed before exit via the <tt>release</tt>
--   function. This is a highly recommended optimization, as it will ensure
--   that scarce resources are freed early. Note that calling
--   <tt>release</tt> will deregister the action, so that a release action
--   will only ever be called once.
--   
--   Since 0.3.0
data ResourceT (m :: * -> *) a :: (* -> *) -> * -> *

-- | Unlifted version of <a>runResourceT</a>.
runResourceT :: MonadUnliftIO m => ResourceT m a -> m a

-- | Lifted version of <a>liftResourceT</a>.
liftResourceT :: MonadIO m => ResourceT IO a -> ResourceT m a


-- | Unlifted <a>Data.IORef</a>.
module UnliftIO.IORef

-- | A mutable variable in the <a>IO</a> monad
data IORef a :: * -> *

-- | Lifted <a>newIORef</a>.
newIORef :: MonadIO m => a -> m (IORef a)

-- | Lifted <a>readIORef</a>.
readIORef :: MonadIO m => IORef a -> m a

-- | Lifted <a>writeIORef</a>.
writeIORef :: MonadIO m => IORef a -> a -> m ()

-- | Lifted <a>modifyIORef</a>.
modifyIORef :: MonadIO m => IORef a -> (a -> a) -> m ()

-- | Lifted <a>modifyIORef'</a>.
modifyIORef' :: MonadIO m => IORef a -> (a -> a) -> m ()

-- | Lifted <a>atomicModifyIORef</a>.
atomicModifyIORef :: MonadIO m => IORef a -> (a -> (a, b)) -> m b

-- | Lifted <a>atomicModifyIORef'</a>.
atomicModifyIORef' :: MonadIO m => IORef a -> (a -> (a, b)) -> m b

-- | Lifted <a>atomicWriteIORef</a>.
atomicWriteIORef :: MonadIO m => IORef a -> a -> m ()

-- | Unlifted <a>mkWeakIORef</a>.
mkWeakIORef :: MonadUnliftIO m => IORef a -> m () -> m (Weak (IORef a))


-- | Unlifted <a>System.IO</a>.
module UnliftIO.IO

-- | See <a>openFile</a>
data IOMode :: *
ReadMode :: IOMode
WriteMode :: IOMode
AppendMode :: IOMode
ReadWriteMode :: IOMode

-- | Haskell defines operations to read and write characters from and to
--   files, represented by values of type <tt>Handle</tt>. Each value of
--   this type is a <i>handle</i>: a record used by the Haskell run-time
--   system to <i>manage</i> I/O with file system objects. A handle has at
--   least the following properties:
--   
--   <ul>
--   <li>whether it manages input or output or both;</li>
--   <li>whether it is <i>open</i>, <i>closed</i> or
--   <i>semi-closed</i>;</li>
--   <li>whether the object is seekable;</li>
--   <li>whether buffering is disabled, or enabled on a line or block
--   basis;</li>
--   <li>a buffer (whose length may be zero).</li>
--   </ul>
--   
--   Most handles will also have a current I/O position indicating where
--   the next input or output operation will occur. A handle is
--   <i>readable</i> if it manages only input or both input and output;
--   likewise, it is <i>writable</i> if it manages only output or both
--   input and output. A handle is <i>open</i> when first allocated. Once
--   it is closed it can no longer be used for either input or output,
--   though an implementation cannot re-use its storage while references
--   remain to it. Handles are in the <a>Show</a> and <a>Eq</a> classes.
--   The string produced by showing a handle is system dependent; it should
--   include enough information to identify the handle for debugging. A
--   handle is equal according to <a>==</a> only to itself; no attempt is
--   made to compare the internal state of different handles for equality.
data Handle :: *

-- | Unlifted version of <a>withFile</a>.
withFile :: MonadUnliftIO m => FilePath -> IOMode -> (Handle -> m a) -> m a

-- | Unlifted version of <a>withBinaryFile</a>.
withBinaryFile :: MonadUnliftIO m => FilePath -> IOMode -> (Handle -> m a) -> m a


-- | Unlifted <a>Control.Exception</a>, with extra async exception safety
--   and more helper functions.
module UnliftIO.Exception

-- | Synchronously throw the given exception.
throwIO :: (MonadIO m, Exception e) => e -> m a

-- | A convenience function for throwing a user error. This is useful for
--   cases where it would be too high a burden to define your own exception
--   type.
--   
--   This throws an exception of type <a>StringException</a>. When GHC
--   supports it (base 4.9 and GHC 8.0 and onward), it includes a call
--   stack.
throwString :: (MonadIO m, HasCallStack) => String -> m a

-- | Exception type thrown by <a>throwString</a>.
--   
--   Note that the second field of the data constructor depends on GHC/base
--   version. For base 4.9 and GHC 8.0 and later, the second field is a
--   call stack. Previous versions of GHC and base do not support call
--   stacks, and the field is simply unit (provided to make pattern
--   matching across GHC versions easier).
data StringException
StringException :: String -> CallStack -> StringException

-- | Smart constructor for a <a>StringException</a> that deals with the
--   call stack.
stringException :: HasCallStack => String -> StringException

-- | Throw an asynchronous exception to another thread.
--   
--   Synchronously typed exceptions will be wrapped into an
--   <a>AsyncExceptionWrapper</a>, see
--   <a>https://github.com/fpco/safe-exceptions#determining-sync-vs-async</a>.
--   
--   It's usually a better idea to use the <a>UnliftIO.Async</a> module,
--   see <a>https://github.com/fpco/safe-exceptions#quickstart</a>.
throwTo :: (Exception e, MonadIO m) => ThreadId -> e -> m ()

-- | Generate a pure value which, when forced, will synchronously throw the
--   given exception.
--   
--   Generally it's better to avoid using this function and instead use
--   <a>throwIO</a>, see
--   <a>https://github.com/fpco/safe-exceptions#quickstart</a>.
impureThrow :: Exception e => e -> a

-- | Unwrap an <a>Either</a> value, throwing its <a>Left</a> value as a
--   runtime exception via <a>throwIO</a> if present.
fromEither :: (Exception e, MonadIO m) => Either e a -> m a

-- | Same as <a>fromEither</a>, but works on an <a>IO</a>-wrapped
--   <a>Either</a>.
fromEitherIO :: (Exception e, MonadIO m) => IO (Either e a) -> m a

-- | Same as <a>fromEither</a>, but works on an <tt>m</tt>-wrapped
--   <a>Either</a>.
fromEitherM :: (Exception e, MonadIO m) => m (Either e a) -> m a

-- | Unlifted <a>catch</a>, but will not catch asynchronous exceptions.
catch :: (MonadUnliftIO m, Exception e) => m a -> (e -> m a) -> m a

-- | <a>catch</a> specialized to only catching <a>IOException</a>s.
catchIO :: MonadUnliftIO m => m a -> (IOException -> m a) -> m a

-- | <a>catch</a> specialized to catch all synchronous exception.
catchAny :: MonadUnliftIO m => m a -> (SomeException -> m a) -> m a

-- | Same as <a>catch</a>, but fully force evaluation of the result value
--   to find all impure exceptions.
catchDeep :: (MonadUnliftIO m, Exception e, NFData a) => m a -> (e -> m a) -> m a

-- | <a>catchDeep</a> specialized to catch all synchronous exception.
catchAnyDeep :: (NFData a, MonadUnliftIO m) => m a -> (SomeException -> m a) -> m a

-- | <a>catchJust</a> is like <a>catch</a> but it takes an extra argument
--   which is an exception predicate, a function which selects which type
--   of exceptions we're interested in.
catchJust :: (MonadUnliftIO m, Exception e) => (e -> Maybe b) -> m a -> (b -> m a) -> m a

-- | Flipped version of <a>catch</a>.
handle :: (MonadUnliftIO m, Exception e) => (e -> m a) -> m a -> m a

-- | <a>handle</a> specialized to only catching <a>IOException</a>s.
handleIO :: MonadUnliftIO m => (IOException -> m a) -> m a -> m a

-- | Flipped version of <a>catchAny</a>.
handleAny :: MonadUnliftIO m => (SomeException -> m a) -> m a -> m a

-- | Flipped version of <a>catchDeep</a>.
handleDeep :: (MonadUnliftIO m, Exception e, NFData a) => (e -> m a) -> m a -> m a

-- | Flipped version of <a>catchAnyDeep</a>.
handleAnyDeep :: (MonadUnliftIO m, NFData a) => (SomeException -> m a) -> m a -> m a

-- | Flipped <a>catchJust</a>.
handleJust :: (MonadUnliftIO m, Exception e) => (e -> Maybe b) -> (b -> m a) -> m a -> m a

-- | Unlifted <a>try</a>, but will not catch asynchronous exceptions.
try :: (MonadUnliftIO m, Exception e) => m a -> m (Either e a)

-- | <a>try</a> specialized to only catching <a>IOException</a>s.
tryIO :: MonadUnliftIO m => m a -> m (Either IOException a)

-- | <a>try</a> specialized to catch all synchronous exceptions.
tryAny :: MonadUnliftIO m => m a -> m (Either SomeException a)

-- | Same as <a>try</a>, but fully force evaluation of the result value to
--   find all impure exceptions.
tryDeep :: (MonadUnliftIO m, Exception e, NFData a) => m a -> m (Either e a)

-- | <a>tryDeep</a> specialized to catch all synchronous exceptions.
tryAnyDeep :: (MonadUnliftIO m, NFData a) => m a -> m (Either SomeException a)

-- | A variant of <a>try</a> that takes an exception predicate to select
--   which exceptions are caught.
tryJust :: (MonadUnliftIO m, Exception e) => (e -> Maybe b) -> m a -> m (Either b a)

-- | Generalized version of <a>Handler</a>.
data Handler m a
Handler :: (e -> m a) -> Handler m a

-- | Same as upstream <a>catches</a>, but will not catch asynchronous
--   exceptions.
catches :: MonadUnliftIO m => m a -> [Handler m a] -> m a

-- | Same as <a>catches</a>, but fully force evaluation of the result value
--   to find all impure exceptions.
catchesDeep :: (MonadUnliftIO m, NFData a) => m a -> [Handler m a] -> m a

-- | Async safe version of <a>onException</a>.
onException :: MonadUnliftIO m => m a -> m b -> m a

-- | Async safe version of <a>bracket</a>.
bracket :: MonadUnliftIO m => m a -> (a -> m b) -> (a -> m c) -> m c

-- | Async safe version of <a>bracket_</a>.
bracket_ :: MonadUnliftIO m => m a -> m b -> m c -> m c

-- | Async safe version of <a>finally</a>.
finally :: MonadUnliftIO m => m a -> m b -> m a

-- | Like <a>onException</a>, but provides the handler the thrown
--   exception.
withException :: (MonadUnliftIO m, Exception e) => m a -> (e -> m b) -> m a

-- | Async safe version of <a>bracketOnError</a>.
bracketOnError :: MonadUnliftIO m => m a -> (a -> m b) -> (a -> m c) -> m c

-- | A variant of <a>bracketOnError</a> where the return value from the
--   first computation is not required.
bracketOnError_ :: MonadUnliftIO m => m a -> m b -> m c -> m c

-- | Wrap up an asynchronous exception to be treated as a synchronous
--   exception.
--   
--   This is intended to be created via <a>toSyncException</a>.
data SyncExceptionWrapper
SyncExceptionWrapper :: e -> SyncExceptionWrapper

-- | Convert an exception into a synchronous exception.
--   
--   For synchronous exceptions, this is the same as <a>toException</a>.
--   For asynchronous exceptions, this will wrap up the exception with
--   <a>SyncExceptionWrapper</a>.
toSyncException :: Exception e => e -> SomeException

-- | Wrap up a synchronous exception to be treated as an asynchronous
--   exception.
--   
--   This is intended to be created via <a>toAsyncException</a>.
data AsyncExceptionWrapper
AsyncExceptionWrapper :: e -> AsyncExceptionWrapper

-- | Convert an exception into an asynchronous exception.
--   
--   For asynchronous exceptions, this is the same as <a>toException</a>.
--   For synchronous exceptions, this will wrap up the exception with
--   <a>AsyncExceptionWrapper</a>.
toAsyncException :: Exception e => e -> SomeException

-- | Check if the given exception is synchronous.
isSyncException :: Exception e => e -> Bool

-- | Check if the given exception is asynchronous.
isAsyncException :: Exception e => e -> Bool

-- | Unlifted version of <a>mask</a>.
mask :: MonadUnliftIO m => ((forall a. m a -> m a) -> m b) -> m b

-- | Unlifted version of <a>uninterruptibleMask</a>.
uninterruptibleMask :: MonadUnliftIO m => ((forall a. m a -> m a) -> m b) -> m b

-- | Unlifted version of <a>mask_</a>.
mask_ :: MonadUnliftIO m => m a -> m a

-- | Unlifted version of <a>uninterruptibleMask_</a>.
uninterruptibleMask_ :: MonadUnliftIO m => m a -> m a

-- | Lifted version of <a>evaluate</a>.
evaluate :: MonadIO m => a -> m a

-- | Deeply evaluate a value using <a>evaluate</a> and <a>NFData</a>.
evaluateDeep :: (MonadIO m, NFData a) => 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, Typeable)
--   
--   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
--       deriving Typeable
--   
--   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
--       deriving Typeable
--   
--   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 (Typeable, 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 <tt>catch</tt> e -&gt; putStrLn ("Caught " ++ show (e :: MismatchedParentheses))
--   Caught MismatchedParentheses
--   *Main&gt; throw MismatchedParentheses <tt>catch</tt> e -&gt; putStrLn ("Caught " ++ show (e :: SomeFrontendException))
--   Caught MismatchedParentheses
--   *Main&gt; throw MismatchedParentheses <tt>catch</tt> e -&gt; putStrLn ("Caught " ++ show (e :: SomeCompilerException))
--   Caught MismatchedParentheses
--   *Main&gt; throw MismatchedParentheses <tt>catch</tt> 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 class <a>Typeable</a> allows a concrete representation of a type
--   to be calculated.
class Typeable k (a :: k)

-- | 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 :: *
[SomeException] :: SomeException

-- | Superclass for asynchronous exceptions.
data SomeAsyncException :: *
[SomeAsyncException] :: SomeAsyncException

-- | Exceptions that occur in the <tt>IO</tt> monad. An
--   <tt>IOException</tt> records a more specific error type, a descriptive
--   string and maybe the handle that was used when the error was flagged.
data IOException :: *

-- | If the first argument evaluates to <a>True</a>, then the result is the
--   second argument. Otherwise an <tt>AssertionFailed</tt> exception is
--   raised, containing a <a>String</a> with the source file and line
--   number of the call to <a>assert</a>.
--   
--   Assertions can normally be turned on or off with a compiler flag (for
--   GHC, assertions are normally on unless optimisation is turned on with
--   <tt>-O</tt> or the <tt>-fignore-asserts</tt> option is given). When
--   assertions are turned off, the first argument to <a>assert</a> is
--   ignored, and the second argument is returned as the result.
assert :: Bool -> a -> a
instance GHC.Show.Show UnliftIO.Exception.SyncExceptionWrapper
instance GHC.Exception.Exception UnliftIO.Exception.SyncExceptionWrapper
instance GHC.Show.Show UnliftIO.Exception.AsyncExceptionWrapper
instance GHC.Exception.Exception UnliftIO.Exception.AsyncExceptionWrapper
instance GHC.Show.Show UnliftIO.Exception.StringException
instance GHC.Exception.Exception UnliftIO.Exception.StringException


-- | Temporary file and directory support.
--   
--   Strongly inspired by/stolen from the
--   <a>https://github.com/feuerbach/temporary</a> package.
module UnliftIO.Temporary

-- | Create and use a temporary file in the system standard temporary
--   directory.
--   
--   Behaves exactly the same as <a>withTempFile</a>, except that the
--   parent temporary directory will be that returned by
--   <a>getCanonicalTemporaryDirectory</a>.
withSystemTempFile :: MonadUnliftIO m => String -> (FilePath -> Handle -> m a) -> m a

-- | Create and use a temporary directory in the system standard temporary
--   directory.
--   
--   Behaves exactly the same as <a>withTempDirectory</a>, except that the
--   parent temporary directory will be that returned by
--   <a>getCanonicalTemporaryDirectory</a>.
withSystemTempDirectory :: MonadUnliftIO m => String -> (FilePath -> m a) -> m a

-- | Use a temporary filename that doesn't already exist.
--   
--   Creates a new temporary file inside the given directory, making use of
--   the template. The temp file is deleted after use. For example:
--   
--   <pre>
--   withTempFile "src" "sdist." $ \tmpFile hFile -&gt; do ...
--   </pre>
--   
--   The <tt>tmpFile</tt> will be file in the given directory, e.g.
--   <tt>src/sdist.342</tt>.
withTempFile :: MonadUnliftIO m => FilePath -> String -> (FilePath -> Handle -> m a) -> m a

-- | Create and use a temporary directory.
--   
--   Creates a new temporary directory inside the given directory, making
--   use of the template. The temp directory is deleted after use. For
--   example:
--   
--   <pre>
--   withTempDirectory "src" "sdist." $ \tmpDir -&gt; do ...
--   </pre>
--   
--   The <tt>tmpDir</tt> will be a new subdirectory of the given directory,
--   e.g. <tt>src/sdist.342</tt>.
withTempDirectory :: MonadUnliftIO m => FilePath -> String -> (FilePath -> m a) -> m a


-- | Lifted <a>Control.Concurrent.Chan</a>.
module UnliftIO.Chan

-- | <a>Chan</a> is an abstract type representing an unbounded FIFO
--   channel.
data Chan a :: * -> *

-- | Lifted <a>newChan</a>.
newChan :: MonadIO m => m (Chan a)

-- | Lifted <a>writeChan</a>.
writeChan :: MonadIO m => Chan a -> a -> m ()

-- | Lifted <a>readChan</a>.
readChan :: MonadIO m => Chan a -> m a

-- | Lifted <a>dupChan</a>.
dupChan :: MonadIO m => Chan a -> m (Chan a)

-- | Lifted <a>getChanContents</a>.
getChanContents :: MonadIO m => Chan a -> m [a]

-- | Lifted <a>writeList2Chan</a>.
writeList2Chan :: MonadIO m => Chan a -> [a] -> m ()


-- | Unlifted <a>Control.Concurrent</a>.
--   
--   This module is not reexported by <a>UnliftIO</a>, use it only if
--   <a>UnliftIO.Async</a> is not enough.
module UnliftIO.Concurrent

-- | A <a>ThreadId</a> is an abstract type representing a handle to a
--   thread. <a>ThreadId</a> is an instance of <a>Eq</a>, <a>Ord</a> and
--   <a>Show</a>, where the <a>Ord</a> instance implements an arbitrary
--   total ordering over <a>ThreadId</a>s. The <a>Show</a> instance lets
--   you convert an arbitrary-valued <a>ThreadId</a> to string form;
--   showing a <a>ThreadId</a> value is occasionally useful when debugging
--   or diagnosing the behaviour of a concurrent program.
--   
--   <i>Note</i>: in GHC, if you have a <a>ThreadId</a>, you essentially
--   have a pointer to the thread itself. This means the thread itself
--   can't be garbage collected until you drop the <a>ThreadId</a>. This
--   misfeature will hopefully be corrected at a later date.
data ThreadId :: *

-- | Lifted version of <a>myThreadId</a>.
myThreadId :: MonadIO m => m ThreadId

-- | Unlifted version of <a>forkIO</a>.
forkIO :: MonadUnliftIO m => m () -> m ThreadId

-- | Unlifted version of <a>forkIOWithUnmask</a>.
forkWithUnmask :: MonadUnliftIO m => ((forall a. m a -> m a) -> m ()) -> m ThreadId

-- | Unlifted version of <a>forkFinally</a>.
forkFinally :: MonadUnliftIO m => m a -> (Either SomeException a -> m ()) -> m ThreadId

-- | Lifted version of <a>killThread</a>.
killThread :: MonadIO m => ThreadId -> m ()

-- | Throw an asynchronous exception to another thread.
--   
--   Synchronously typed exceptions will be wrapped into an
--   <a>AsyncExceptionWrapper</a>, see
--   <a>https://github.com/fpco/safe-exceptions#determining-sync-vs-async</a>.
--   
--   It's usually a better idea to use the <a>UnliftIO.Async</a> module,
--   see <a>https://github.com/fpco/safe-exceptions#quickstart</a>.
throwTo :: (Exception e, MonadIO m) => ThreadId -> e -> m ()

-- | Unlifted version of <a>forkOn</a>.
forkOn :: MonadUnliftIO m => Int -> m () -> m ThreadId

-- | Unlifted version of <a>forkOnWithUnmask</a>.
forkOnWithUnmask :: MonadUnliftIO m => Int -> ((forall a. m a -> m a) -> m ()) -> m ThreadId

-- | Lifted version of <a>getNumCapabilities</a>.
getNumCapabilities :: MonadIO m => m Int

-- | Lifted version of <a>setNumCapabilities</a>.
setNumCapabilities :: MonadIO m => Int -> m ()

-- | Lifted version of <a>threadCapability</a>.
threadCapability :: MonadIO m => ThreadId -> m (Int, Bool)

-- | Lifted version of <a>yield</a>.
yield :: MonadIO m => m ()

-- | Lifted version of <a>threadDelay</a>.
threadDelay :: MonadIO m => Int -> m ()

-- | Lifted version of <a>threadWaitRead</a>.
threadWaitRead :: MonadIO m => Fd -> m ()

-- | Lifted version of <a>threadWaitWrite</a>.
threadWaitWrite :: MonadIO m => Fd -> m ()

-- | <a>True</a> if bound threads are supported. If
--   <tt>rtsSupportsBoundThreads</tt> is <a>False</a>,
--   <a>isCurrentThreadBound</a> will always return <a>False</a> and both
--   <a>forkOS</a> and <a>runInBoundThread</a> will fail.
rtsSupportsBoundThreads :: Bool

-- | Unflifted version of <a>forkOS</a>.
forkOS :: MonadUnliftIO m => m () -> m ThreadId

-- | Lifted version of <a>isCurrentThreadBound</a>.
isCurrentThreadBound :: MonadIO m => m Bool

-- | Unlifted version of <a>runInBoundThread</a>.
runInBoundThread :: MonadUnliftIO m => m a -> m a

-- | Unlifted version of <a>runInUnboundThread</a>.
runInUnboundThread :: MonadUnliftIO m => m a -> m a

-- | Lifted version of <a>mkWeakThreadId</a>.
mkWeakThreadId :: MonadIO m => ThreadId -> m (Weak ThreadId)


-- | Unlifted <a>Control.Concurrent.Async</a>.
module UnliftIO.Async

-- | An asynchronous action spawned by <a>async</a> or <a>withAsync</a>.
--   Asynchronous actions are executed in a separate thread, and operations
--   are provided for waiting for asynchronous actions to complete and
--   obtaining their results (see e.g. <a>wait</a>).
data Async a :: * -> *

-- | Unlifted <a>async</a>.
async :: MonadUnliftIO m => m a -> m (Async a)

-- | Unlifted <a>asyncBound</a>.
asyncBound :: MonadUnliftIO m => m a -> m (Async a)

-- | Unlifted <a>asyncOn</a>.
asyncOn :: MonadUnliftIO m => Int -> m a -> m (Async a)

-- | Unlifted <a>asyncWithUnmask</a>.
asyncWithUnmask :: MonadUnliftIO m => ((forall b. m b -> m b) -> m a) -> m (Async a)

-- | Unlifted <a>asyncOnWithUnmask</a>.
asyncOnWithUnmask :: MonadUnliftIO m => Int -> ((forall b. m b -> m b) -> m a) -> m (Async a)

-- | Unlifted <a>withAsync</a>.
withAsync :: MonadUnliftIO m => m a -> (Async a -> m b) -> m b

-- | Unlifted <a>withAsyncBound</a>.
withAsyncBound :: MonadUnliftIO m => m a -> (Async a -> m b) -> m b

-- | Unlifted <a>withAsyncOn</a>.
withAsyncOn :: MonadUnliftIO m => Int -> m a -> (Async a -> m b) -> m b

-- | Unlifted <a>withAsyncWithUnmask</a>.
withAsyncWithUnmask :: MonadUnliftIO m => ((forall c. m c -> m c) -> m a) -> (Async a -> m b) -> m b

-- | Unlifted <a>withAsyncOnWithMask</a>.
withAsyncOnWithUnmask :: MonadUnliftIO m => Int -> ((forall c. m c -> m c) -> m a) -> (Async a -> m b) -> m b

-- | Lifted <a>wait</a>.
wait :: MonadIO m => Async a -> m a

-- | Lifted <a>poll</a>.
poll :: MonadIO m => Async a -> m (Maybe (Either SomeException a))

-- | Lifted <a>waitCatch</a>.
waitCatch :: MonadIO m => Async a -> m (Either SomeException a)

-- | Lifted <a>cancel</a>.
cancel :: MonadIO m => Async a -> m ()

-- | Lifted <a>uninterruptibleCancel</a>.
uninterruptibleCancel :: MonadIO m => Async a -> m ()

-- | Lifted <a>cancelWith</a>. Additionally uses <a>toAsyncException</a> to
--   ensure async exception safety.
cancelWith :: (Exception e, MonadIO m) => Async a -> e -> m ()

-- | Returns the <a>ThreadId</a> of the thread running the given
--   <a>Async</a>.
asyncThreadId :: Async a -> ThreadId

-- | A version of <a>wait</a> that can be used inside an STM transaction.
waitSTM :: Async a -> STM a

-- | A version of <a>poll</a> that can be used inside an STM transaction.
pollSTM :: Async a -> STM (Maybe (Either SomeException a))

-- | A version of <a>waitCatch</a> that can be used inside an STM
--   transaction.
waitCatchSTM :: Async a -> STM (Either SomeException a)

-- | Lifted <a>waitAny</a>.
waitAny :: MonadIO m => [Async a] -> m (Async a, a)

-- | Lifted <a>waitAnyCatch</a>.
waitAnyCatch :: MonadIO m => [Async a] -> m (Async a, Either SomeException a)

-- | Lifted <a>waitAnyCancel</a>.
waitAnyCancel :: MonadIO m => [Async a] -> m (Async a, a)

-- | Lifted <a>waitAnyCatchCancel</a>.
waitAnyCatchCancel :: MonadIO m => [Async a] -> m (Async a, Either SomeException a)

-- | Lifted <a>waitEither</a>.
waitEither :: MonadIO m => Async a -> Async b -> m (Either a b)

-- | Lifted <a>waitEitherCatch</a>.
waitEitherCatch :: MonadIO m => Async a -> Async b -> m (Either (Either SomeException a) (Either SomeException b))

-- | Lifted <a>waitEitherCancel</a>.
waitEitherCancel :: MonadIO m => Async a -> Async b -> m (Either a b)

-- | Lifted <a>waitEitherCatchCancel</a>.
waitEitherCatchCancel :: MonadIO m => Async a -> Async b -> m (Either (Either SomeException a) (Either SomeException b))

-- | Lifted <a>waitEither_</a>.
waitEither_ :: MonadIO m => Async a -> Async b -> m ()

-- | Lifted <a>waitBoth</a>.
waitBoth :: MonadIO m => Async a -> Async b -> m (a, b)

-- | A version of <a>waitAny</a> that can be used inside an STM
--   transaction.
waitAnySTM :: [Async a] -> STM (Async a, a)

-- | A version of <a>waitAnyCatch</a> that can be used inside an STM
--   transaction.
waitAnyCatchSTM :: [Async a] -> STM (Async a, Either SomeException a)

-- | A version of <a>waitEither</a> that can be used inside an STM
--   transaction.
waitEitherSTM :: Async a -> Async b -> STM (Either a b)

-- | A version of <a>waitEitherCatch</a> that can be used inside an STM
--   transaction.
waitEitherCatchSTM :: Async a -> Async b -> STM (Either (Either SomeException a) (Either SomeException b))

-- | A version of <a>waitEither_</a> that can be used inside an STM
--   transaction.
waitEitherSTM_ :: Async a -> Async b -> STM ()

-- | A version of <a>waitBoth</a> that can be used inside an STM
--   transaction.
waitBothSTM :: Async a -> Async b -> STM (a, b)

-- | Lifted <a>link</a>.
link :: MonadIO m => Async a -> m ()

-- | Lifted <a>link2</a>.
link2 :: MonadIO m => Async a -> Async b -> m ()

-- | Unlifted <a>race</a>.
race :: MonadUnliftIO m => m a -> m b -> m (Either a b)

-- | Unlifted <a>race_</a>.
race_ :: MonadUnliftIO m => m a -> m b -> m ()

-- | Unlifted <a>concurrently</a>.
concurrently :: MonadUnliftIO m => m a -> m b -> m (a, b)

-- | Unlifted <a>concurrently_</a>.
concurrently_ :: MonadUnliftIO m => m a -> m b -> m ()

-- | Unlifted <a>mapConcurrently</a>.
mapConcurrently :: MonadUnliftIO m => Traversable t => (a -> m b) -> t a -> m (t b)

-- | Unlifted <a>forConcurrently</a>.
forConcurrently :: MonadUnliftIO m => Traversable t => t a -> (a -> m b) -> m (t b)

-- | Unlifted <a>mapConcurrently_</a>.
mapConcurrently_ :: MonadUnliftIO m => Foldable f => (a -> m b) -> f a -> m ()

-- | Unlifted <a>forConcurrently_</a>.
forConcurrently_ :: MonadUnliftIO m => Foldable f => f a -> (a -> m b) -> m ()

-- | Unlifted <a>replicateConcurrently</a>.
replicateConcurrently :: MonadUnliftIO m => Int -> m a -> m [a]

-- | Unlifted <a>replicateConcurrently_</a>.
replicateConcurrently_ :: MonadUnliftIO m => Int -> m a -> m ()

-- | Unlifted <a>Concurrently</a>.
newtype Concurrently m a
Concurrently :: m a -> Concurrently m a
[runConcurrently] :: Concurrently m a -> m a
instance GHC.Base.Monad m => GHC.Base.Functor (UnliftIO.Async.Concurrently m)
instance Control.Monad.IO.Unlift.MonadUnliftIO m => GHC.Base.Applicative (UnliftIO.Async.Concurrently m)
instance Control.Monad.IO.Unlift.MonadUnliftIO m => GHC.Base.Alternative (UnliftIO.Async.Concurrently m)
instance (Control.Monad.IO.Unlift.MonadUnliftIO m, Data.Semigroup.Semigroup a) => Data.Semigroup.Semigroup (UnliftIO.Async.Concurrently m a)
instance (Data.Semigroup.Semigroup a, GHC.Base.Monoid a, Control.Monad.IO.Unlift.MonadUnliftIO m) => GHC.Base.Monoid (UnliftIO.Async.Concurrently m a)

module UnliftIO
