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


-- | Closable, fair, single-wakeup channel type that avoids 0
--   reader space leaks.
--   
--   <b>WARNING:</b> While the code in this library should be fairly stable
--   and production, the API is something I'm still working on. API changes
--   will follow the PVP, but <b>expect</b> breaking API changes in future
--   versions!
--   
--   A closable, fair, single-wakeup channel that avoids the 0 reader space
--   leak that <tt><a>Control.Concurrent.Chan</a></tt> from base suffers
--   from.
--   
--   The <tt>Chan</tt> type from <tt><a>Control.Concurrent.Chan</a></tt>
--   consists of both a read and write end combined into a single value.
--   This means there is always at least 1 read end for a <tt>Chan</tt>,
--   which keeps any values written to it alive. This is a problem for
--   applications/libraries that want to have a channel that can have zero
--   listeners.
--   
--   Suppose we have an library that produces events and we want to let
--   users register to receive events. If we use a channel and write all
--   events to it, we would like to drop and garbage collect any events
--   that take place when there are 0 listeners. The always present read
--   end of <tt>Chan</tt> from base makes this impossible. We end up with a
--   <tt>Chan</tt> that forever accumulates more and more events that will
--   never get removed, resulting in a memory leak.
--   
--   <tt><a>BroadcastChan</a></tt> splits channels into separate read and
--   write ends. Any message written to a a channel with no existing read
--   end is immediately dropped so it can be garbage collected. Once a read
--   end is created, all messages written to the channel will be accessible
--   to that read end.
--   
--   Once all read ends for a channel have disappeared and been garbage
--   collected, the channel will return to dropping messages as soon as
--   they are written.
--   
--   <b>Why should I use <a>BroadcastChan</a> over
--   <a>Control.Concurrent.Chan</a>?</b>
--   
--   <ul>
--   <li><tt><a>BroadcastChan</a></tt> is closable,</li>
--   <li><tt><a>BroadcastChan</a></tt> has no 0 reader space leak,</li>
--   <li><tt><a>BroadcastChan</a></tt> has comparable or better
--   performance.</li>
--   </ul>
--   
--   <b>Why should I use <a>BroadcastChan</a> over various (closable) STM
--   channels?</b>
--   
--   <ul>
--   <li><tt><a>BroadcastChan</a></tt> is single-wakeup,</li>
--   <li><tt><a>BroadcastChan</a></tt> is fair,</li>
--   <li><tt><a>BroadcastChan</a></tt> performs better under
--   contention.</li>
--   </ul>
@package broadcast-chan
@version 0.2.1.2


-- | Functions in this module are *NOT* intended to be used by regular
--   users of the library. Rather, they are intended for implementing
--   parallel processing libraries on top of <tt>broadcast-chan</tt>, such
--   as <tt>broadcast-chan-conduit</tt>.
--   
--   This module, while not for end users, is considered part of the public
--   API, so users can rely on PVP bounds to avoid breakage due to changes
--   to this module.
module BroadcastChan.Extra

-- | Action to take when an exception occurs while processing an element.
data Action

-- | Drop the current element and continue processing.
Drop :: Action

-- | Retry by appending the current element to the queue of remaining
--   elements.
Retry :: Action

-- | Stop all processing and reraise the exception.
Terminate :: Action

-- | Allocation, cleanup, and work actions for parallel processing. These
--   should be passed to an appropriate <tt>bracketOnError</tt> function.
data BracketOnError (m :: Type -> Type) r
Bracket :: IO [Weak ThreadId] -> ([Weak ThreadId] -> IO ()) -> m r -> BracketOnError (m :: Type -> Type) r

-- | Allocation action that spawn threads and sets up handlers.
[allocate] :: BracketOnError (m :: Type -> Type) r -> IO [Weak ThreadId]

-- | Cleanup action that handles exceptional termination
[cleanup] :: BracketOnError (m :: Type -> Type) r -> [Weak ThreadId] -> IO ()

-- | Action that performs actual processing and waits for processing to
--   finish and threads to terminate.
[action] :: BracketOnError (m :: Type -> Type) r -> m r

-- | Exception handler for parallel processing.
data Handler (m :: Type -> Type) a

-- | Always take the specified <a>Action</a>.
Simple :: Action -> Handler (m :: Type -> Type) a

-- | Allow inspection of the element, exception, and execution of monadic
--   actions before deciding the <a>Action</a> to take.
Handle :: (a -> SomeException -> m Action) -> Handler (m :: Type -> Type) a

-- | Datatype for specifying additional setup/cleanup around forking
--   threads. Used by <a>runParallelWith</a> and <a>runParallelWith_</a> to
--   fix resource management in <tt>broadcast-chan-conduit</tt>.
--   
--   If the allocation action can fail/abort with an exception it
--   <b>MUST</b> take care not to leak resources in these cases. In other
--   words, IFF <a>setupFork</a> succeeds then this library will ensure the
--   corresponding cleanup runs.
data ThreadBracket
ThreadBracket :: IO () -> IO () -> IO () -> ThreadBracket

-- | Setup action to run before spawning a new thread.
[setupFork] :: ThreadBracket -> IO ()

-- | Normal cleanup action upon thread termination.
[cleanupFork] :: ThreadBracket -> IO ()

-- | Exceptional cleanup action in case thread terminates due to an
--   exception.
[cleanupForkError] :: ThreadBracket -> IO ()

-- | Convenience function for changing the monad the exception handler runs
--   in.
mapHandler :: (m Action -> n Action) -> Handler m a -> Handler n a

-- | Sets up parallel processing.
--   
--   The workhorses of this function are the output yielder and "stream"
--   processing functions.
--   
--   The output yielder is responsible for handling the produced <tt>b</tt>
--   values, which if can either yield downstream (<a>Left</a>) when used
--   with something like <tt>conduit</tt> or <tt>pipes</tt>, or fold into a
--   single results (<a>Right</a>) when used to run IO in parallel.
--   
--   The stream processing function gets two arguments:
--   
--   <ul>
--   <li><i><tt>a -&gt; m ()</tt></i> Should be used to buffer a number of
--   elements equal to the number of threads.</li>
--   <li><i><tt>a -&gt; m b</tt></i> Which should be used to process the
--   remainder of the element stream via, for example, <a>mapM</a>.</li>
--   </ul>
--   
--   See <a>BroadcastChan</a> or <tt>broadcast-chan-conduit</tt> for
--   examples.
--   
--   The returned <a>BracketOnError</a> has a <a>allocate</a> action that
--   takes care of setting up <a>forkIO</a> threads and exception handlers.
--   The <a>cleanup</a> action ensures all threads are terminate in case of
--   an exception. Finally, <a>action</a> performs the actual parallel
--   processing of elements.
runParallel :: forall a b m n r. (MonadIO m, MonadIO n) => Either (b -> n r) (r -> b -> n r) -> Handler IO a -> Int -> (a -> IO b) -> ((a -> m ()) -> (a -> m (Maybe b)) -> n r) -> n (BracketOnError n r)

-- | Like <a>runParallel</a>, but accepts a setup and cleanup action that
--   will be run before spawning a new thread and upon thread exit
--   respectively.
--   
--   The main use case is to properly manage the resource reference counts
--   of <a>ResourceT</a>.
--   
--   If the setup throws an <a>IO</a> exception or otherwise aborts, it
--   <b>MUST</b> ensure any allocated resource are freed. If it completes
--   without an exception, the cleanup is guaranteed to run (assuming
--   proper use of bracketing with the returned <a>BracketOnError</a>).
runParallelWith :: forall a b m n r. (MonadIO m, MonadIO n) => ThreadBracket -> Either (b -> n r) (r -> b -> n r) -> Handler IO a -> Int -> (a -> IO b) -> ((a -> m ()) -> (a -> m (Maybe b)) -> n r) -> n (BracketOnError n r)

-- | Sets up parallel processing for functions where we ignore the result.
--   
--   The stream processing argument is the workhorse of this function. It
--   gets a (rate-limited) function <tt>a -&gt; m ()</tt> that queues
--   <tt>a</tt> values for processing. This function should be applied to
--   all <tt>a</tt> elements that should be processed. This would be either
--   a partially applied <a>forM_</a> for parallel processing, or something
--   like conduit's <a>mapM_</a> to construct a "sink" for <tt>a</tt>
--   values. See <a>BroadcastChan</a> or <tt>broadcast-chan-conduit</tt>
--   for examples.
--   
--   The returned <a>BracketOnError</a> has a <a>allocate</a> action that
--   takes care of setting up <a>forkIO</a> threads and exception handlers.
--   Th <a>cleanup</a> action ensures all threads are terminate in case of
--   an exception. Finally, <a>action</a> performs the actual parallel
--   processing of elements.
runParallel_ :: (MonadIO m, MonadIO n) => Handler IO a -> Int -> (a -> IO ()) -> ((a -> m ()) -> n r) -> n (BracketOnError n r)

-- | Like <a>runParallel_</a>, but accepts a setup and cleanup action that
--   will be run before spawning a new thread and upon thread exit
--   respectively.
--   
--   The main use case is to properly manage the resource reference counts
--   of <a>ResourceT</a>.
--   
--   If the setup throws an <a>IO</a> exception or otherwise aborts, it
--   <b>MUST</b> ensure any allocated resource are freed. If it completes
--   without an exception, the cleanup is guaranteed to run (assuming
--   proper use of bracketing with the returned <a>BracketOnError</a>).
runParallelWith_ :: (MonadIO m, MonadIO n) => ThreadBracket -> Handler IO a -> Int -> (a -> IO ()) -> ((a -> m ()) -> n r) -> n (BracketOnError n r)
instance GHC.Classes.Eq BroadcastChan.Extra.Action
instance GHC.Internal.Exception.Type.Exception BroadcastChan.Extra.Shutdown
instance GHC.Internal.Show.Show BroadcastChan.Extra.Action
instance GHC.Internal.Show.Show BroadcastChan.Extra.Shutdown


-- | A closable, fair, single-wakeup channel that avoids the 0 reader space
--   leak that <tt><a>Control.Concurrent.Chan</a></tt> from base suffers
--   from.
--   
--   The <tt>Chan</tt> type from <tt><a>Control.Concurrent.Chan</a></tt>
--   consists of both a read and write end combined into a single value.
--   This means there is always at least 1 read end for a <tt>Chan</tt>,
--   which keeps any values written to it alive. This is a problem for
--   applications/libraries that want to have a channel that can have zero
--   listeners.
--   
--   Suppose we have an library that produces events and we want to let
--   users register to receive events. If we use a channel and write all
--   events to it, we would like to drop and garbage collect any events
--   that take place when there are 0 listeners. The always present read
--   end of <tt>Chan</tt> from base makes this impossible. We end up with a
--   <tt>Chan</tt> that forever accumulates more and more events that will
--   never get removed, resulting in a memory leak.
--   
--   <tt><a>BroadcastChan</a></tt> splits channels into separate read and
--   write ends. Any message written to a a channel with no existing read
--   end is immediately dropped so it can be garbage collected. Once a read
--   end is created, all messages written to the channel will be accessible
--   to that read end.
--   
--   Once all read ends for a channel have disappeared and been garbage
--   collected, the channel will return to dropping messages as soon as
--   they are written.
--   
--   <b>Why should I use <a>BroadcastChan</a> over
--   <a>Control.Concurrent.Chan</a>?</b>
--   
--   <ul>
--   <li><tt><a>BroadcastChan</a></tt> is closable,</li>
--   <li><tt><a>BroadcastChan</a></tt> has no 0 reader space leak,</li>
--   <li><tt><a>BroadcastChan</a></tt> has comparable or better
--   performance.</li>
--   </ul>
--   
--   <b>Why should I use <a>BroadcastChan</a> over various (closable) STM
--   channels?</b>
--   
--   <ul>
--   <li><tt><a>BroadcastChan</a></tt> is single-wakeup,</li>
--   <li><tt><a>BroadcastChan</a></tt> is fair,</li>
--   <li><tt><a>BroadcastChan</a></tt> performs better under
--   contention.</li>
--   </ul>
module BroadcastChan

-- | The abstract type representing the read or write end of a
--   <a>BroadcastChan</a>.
data BroadcastChan (dir :: Direction) a

-- | Used with DataKinds as phantom type indicating whether a
--   <a>BroadcastChan</a> value is a read or write end.
data Direction

-- | Indicates a write <a>BroadcastChan</a>
In :: Direction

-- | Indicates a read <a>BroadcastChan</a>
Out :: Direction

-- | Alias for the <a>In</a> type from the <a>Direction</a> kind, allows
--   users to write the <tt><a>BroadcastChan</a> <a>In</a> a</tt> type
--   without enabling <tt>DataKinds</tt>.
type In = 'In

-- | Alias for the <a>Out</a> type from the <a>Direction</a> kind, allows
--   users to write the <tt><a>BroadcastChan</a> <a>Out</a> a</tt> type
--   without enabling <tt>DataKinds</tt>.
type Out = 'Out

-- | Creates a new <a>BroadcastChan</a> write end.
newBroadcastChan :: MonadIO m => m (BroadcastChan In a)

-- | Create a new read end for a <a>BroadcastChan</a>.
--   
--   <ul>
--   <li><i><a>BroadcastChan</a> <a>In</a>:</i> Will receive all messages
--   written to the channel <b>after</b> this read end is created.</li>
--   <li><i><a>BroadcastChan</a> <a>Out</a>:</i> Will receive all currently
--   unread messages and all future messages.</li>
--   </ul>
newBChanListener :: forall m (dir :: Direction) a. MonadIO m => BroadcastChan dir a -> m (BroadcastChan Out a)

-- | Read the next value from the read end of a <a>BroadcastChan</a>.
--   Returns <a>Nothing</a> if the <a>BroadcastChan</a> is closed and
--   empty. See <tt>BroadcastChan.Throw.</tt><a>readBChan</a> for an
--   exception throwing variant.
readBChan :: MonadIO m => BroadcastChan Out a -> m (Maybe a)

-- | Write a value to write end of a <a>BroadcastChan</a>. Any messages
--   written while there are no live read ends are dropped on the floor and
--   can be immediately garbage collected, thus avoiding space leaks.
--   
--   The return value indicates whether the write succeeded, i.e.,
--   <a>True</a> if the message was written, <a>False</a> is the channel is
--   closed. See <tt>BroadcastChan.Throw.</tt><a>writeBChan</a> for an
--   exception throwing variant.
writeBChan :: MonadIO m => BroadcastChan In a -> a -> m Bool

-- | Close a <a>BroadcastChan</a>, disallowing further writes. Returns
--   <a>True</a> if the <a>BroadcastChan</a> was closed. Returns
--   <a>False</a> if the <a>BroadcastChan</a> was <b>already</b> closed.
closeBChan :: MonadIO m => BroadcastChan In a -> m Bool

-- | Check whether a <a>BroadcastChan</a> is closed. <a>True</a> meaning
--   that future read/write operations on the channel will always fail.
--   
--   <ul>
--   <li><i><a>BroadcastChan</a> <a>In</a>:</i> <tt>True</tt> indicates the
--   channel is closed and writes will always fail.<b>Beware of TOC-TOU
--   races</b>: It is possible for a <a>BroadcastChan</a> to be closed by
--   another thread. If multiple threads use the same channel a
--   <a>closeBChan</a> from another thread can result in the channel being
--   closed right after <a>isClosedBChan</a> returns.</li>
--   <li><i><a>BroadcastChan</a> <a>Out</a>:</i> <tt>True</tt> indicates
--   the channel is both closed and empty, meaning reads will always
--   fail.</li>
--   </ul>
isClosedBChan :: forall m (dir :: Direction) a. MonadIO m => BroadcastChan dir a -> m Bool

-- | Return a lazy list representing the messages written to the channel.
--   
--   Uses <a>unsafeInterleaveIO</a> to defer the IO operations.
--   
--   <ul>
--   <li><i><a>BroadcastChan</a> <a>In</a>:</i> The list contains every
--   message written to the channel after this <a>IO</a> action
--   completes.</li>
--   <li><i><a>BroadcastChan</a> <a>Out</a>:</i> The list contains every
--   currently unread message and all future messages. It's safe to keep
--   using the original channel in any thread.Unlike <a>getChanContents</a>
--   from <a>Control.Concurrent</a>, the list resulting from this function
--   is <b>not</b> affected by reads on the input channel. Every message
--   that is unread or written after the <a>IO</a> action completes
--   <b>will</b> end up in the result list.</li>
--   </ul>
getBChanContents :: forall (dir :: Direction) a. BroadcastChan dir a -> IO [a]

-- | Action to take when an exception occurs while processing an element.
data Action

-- | Drop the current element and continue processing.
Drop :: Action

-- | Retry by appending the current element to the queue of remaining
--   elements.
Retry :: Action

-- | Stop all processing and reraise the exception.
Terminate :: Action

-- | Exception handler for parallel processing.
data Handler (m :: Type -> Type) a

-- | Always take the specified <a>Action</a>.
Simple :: Action -> Handler (m :: Type -> Type) a

-- | Allow inspection of the element, exception, and execution of monadic
--   actions before deciding the <a>Action</a> to take.
Handle :: (a -> SomeException -> m Action) -> Handler (m :: Type -> Type) a

-- | Map a monadic function over a <a>Foldable</a>, processing elements in
--   parallel.
--   
--   This function does <b>NOT</b> guarantee that elements are processed in
--   a deterministic order!
parMapM_ :: (Foldable f, MonadUnliftIO m) => Handler m a -> Int -> (a -> m ()) -> f a -> m ()

-- | Like <a>parMapM_</a>, but folds the individual results into single
--   result value.
--   
--   This function does <b>NOT</b> guarantee that elements are processed in
--   a deterministic order!
parFoldMap :: (Foldable f, MonadUnliftIO m) => Handler m a -> Int -> (a -> m b) -> (r -> b -> r) -> r -> f a -> m r

-- | Like <a>parFoldMap</a>, but uses a monadic fold function.
--   
--   This function does <b>NOT</b> guarantee that elements are processed in
--   a deterministic order!
parFoldMapM :: forall a b f m r. (Foldable f, MonadUnliftIO m) => Handler m a -> Int -> (a -> m b) -> (r -> b -> m r) -> r -> f a -> m r

-- | Strict fold of the <a>BroadcastChan</a>​'s messages. Can be used with
--   <a>Control.Foldl</a> from Tekmo's foldl package:
--   
--   <pre>
--   <a>Control.Foldl</a>.<a>purely</a> <a>foldBChan</a> :: (<a>MonadIO</a> m, <a>MonadIO</a> n) =&gt; <a>Fold</a> a b -&gt; <a>BroadcastChan</a> d a -&gt; n (m b)
--   </pre>
--   
--   The result of this function is a nested monadic value to give more
--   fine-grained control/separation between the start of listening for
--   messages and the start of processing. The inner action folds the
--   actual messages and completes when the channel is closed and
--   exhausted. The outer action controls from when on messages are
--   received. Specifically:
--   
--   <ul>
--   <li><i><a>BroadcastChan</a> <a>In</a>:</i> Will process all messages
--   sent after the outer action completes.</li>
--   <li><i><a>BroadcastChan</a> <a>Out</a>:</i> Will process all messages
--   that are unread when the outer action completes, as well as all future
--   messages.After the outer action completes the fold is unaffected by
--   other (concurrent) reads performed on the original channel. So it's
--   safe to reuse the channel.</li>
--   </ul>
foldBChan :: forall m n x a b (d :: Direction). (MonadIO m, MonadIO n) => (x -> a -> x) -> x -> (x -> b) -> BroadcastChan d a -> n (m b)

-- | Strict, monadic fold of the <a>BroadcastChan</a>​'s messages. Can be
--   used with <a>Control.Foldl</a> from Tekmo's foldl package:
--   
--   <pre>
--   <a>Control.Foldl</a>.<a>impurely</a> <a>foldBChanM</a> :: (<a>MonadIO</a> m, <a>MonadIO</a> n) =&gt; <a>FoldM</a> m a b -&gt; <a>BroadcastChan</a> d a -&gt; n (m b)
--   </pre>
--   
--   Has the same behaviour and guarantees as <a>foldBChan</a>.
foldBChanM :: forall m n x a b (d :: Direction). (MonadIO m, MonadIO n) => (x -> a -> m x) -> m x -> (x -> m b) -> BroadcastChan d a -> n (m b)


-- | This module contains convenience functions that clash with names in
--   <a>Prelude</a> and is intended to be imported qualified.
module BroadcastChan.Prelude

-- | <a>mapM_</a> with it's arguments flipped.
forM_ :: MonadIO m => BroadcastChan Out a -> (a -> m b) -> m ()

-- | Map a monadic function over the elements of a <a>BroadcastChan</a>,
--   ignoring the results.
mapM_ :: MonadIO m => (a -> m b) -> BroadcastChan Out a -> m ()


-- | This module is identical to <a>BroadcastChan</a>, but with
--   <tt>BroadcastChan.</tt><a>writeBChan</a> and
--   <tt>BroadcastChan.</tt><a>readBChan</a> replaced with versions that
--   throw an exception, rather than returning results that the user has to
--   inspect to check for success.
module BroadcastChan.Throw

-- | Exception type for <a>BroadcastChan</a> operations.
data BChanError

-- | Attempted to write to closed <a>BroadcastChan</a>
WriteFailed :: BChanError

-- | Attempted to read from an empty closed <a>BroadcastChan</a>
ReadFailed :: BChanError

-- | Like <a>readBChan</a>, but throws a <a>ReadFailed</a> exception when
--   reading from a closed and empty <a>BroadcastChan</a>.
readBChan :: BroadcastChan Out a -> IO a

-- | Like <a>writeBChan</a>, but throws a <a>WriteFailed</a> exception when
--   writing to closed <a>BroadcastChan</a>.
writeBChan :: BroadcastChan In a -> a -> IO ()

-- | The abstract type representing the read or write end of a
--   <a>BroadcastChan</a>.
data BroadcastChan (dir :: Direction) a

-- | Used with DataKinds as phantom type indicating whether a
--   <a>BroadcastChan</a> value is a read or write end.
data Direction

-- | Indicates a write <a>BroadcastChan</a>
In :: Direction

-- | Indicates a read <a>BroadcastChan</a>
Out :: Direction

-- | Alias for the <a>In</a> type from the <a>Direction</a> kind, allows
--   users to write the <tt><a>BroadcastChan</a> <a>In</a> a</tt> type
--   without enabling <tt>DataKinds</tt>.
type In = 'In

-- | Alias for the <a>Out</a> type from the <a>Direction</a> kind, allows
--   users to write the <tt><a>BroadcastChan</a> <a>Out</a> a</tt> type
--   without enabling <tt>DataKinds</tt>.
type Out = 'Out

-- | Creates a new <a>BroadcastChan</a> write end.
newBroadcastChan :: MonadIO m => m (BroadcastChan In a)

-- | Create a new read end for a <a>BroadcastChan</a>.
--   
--   <ul>
--   <li><i><a>BroadcastChan</a> <a>In</a>:</i> Will receive all messages
--   written to the channel <b>after</b> this read end is created.</li>
--   <li><i><a>BroadcastChan</a> <a>Out</a>:</i> Will receive all currently
--   unread messages and all future messages.</li>
--   </ul>
newBChanListener :: forall m (dir :: Direction) a. MonadIO m => BroadcastChan dir a -> m (BroadcastChan Out a)

-- | Close a <a>BroadcastChan</a>, disallowing further writes. Returns
--   <a>True</a> if the <a>BroadcastChan</a> was closed. Returns
--   <a>False</a> if the <a>BroadcastChan</a> was <b>already</b> closed.
closeBChan :: MonadIO m => BroadcastChan In a -> m Bool

-- | Check whether a <a>BroadcastChan</a> is closed. <a>True</a> meaning
--   that future read/write operations on the channel will always fail.
--   
--   <ul>
--   <li><i><a>BroadcastChan</a> <a>In</a>:</i> <tt>True</tt> indicates the
--   channel is closed and writes will always fail.<b>Beware of TOC-TOU
--   races</b>: It is possible for a <a>BroadcastChan</a> to be closed by
--   another thread. If multiple threads use the same channel a
--   <a>closeBChan</a> from another thread can result in the channel being
--   closed right after <a>isClosedBChan</a> returns.</li>
--   <li><i><a>BroadcastChan</a> <a>Out</a>:</i> <tt>True</tt> indicates
--   the channel is both closed and empty, meaning reads will always
--   fail.</li>
--   </ul>
isClosedBChan :: forall m (dir :: Direction) a. MonadIO m => BroadcastChan dir a -> m Bool

-- | Return a lazy list representing the messages written to the channel.
--   
--   Uses <a>unsafeInterleaveIO</a> to defer the IO operations.
--   
--   <ul>
--   <li><i><a>BroadcastChan</a> <a>In</a>:</i> The list contains every
--   message written to the channel after this <a>IO</a> action
--   completes.</li>
--   <li><i><a>BroadcastChan</a> <a>Out</a>:</i> The list contains every
--   currently unread message and all future messages. It's safe to keep
--   using the original channel in any thread.Unlike <a>getChanContents</a>
--   from <a>Control.Concurrent</a>, the list resulting from this function
--   is <b>not</b> affected by reads on the input channel. Every message
--   that is unread or written after the <a>IO</a> action completes
--   <b>will</b> end up in the result list.</li>
--   </ul>
getBChanContents :: forall (dir :: Direction) a. BroadcastChan dir a -> IO [a]

-- | Action to take when an exception occurs while processing an element.
data Action

-- | Drop the current element and continue processing.
Drop :: Action

-- | Retry by appending the current element to the queue of remaining
--   elements.
Retry :: Action

-- | Stop all processing and reraise the exception.
Terminate :: Action

-- | Exception handler for parallel processing.
data Handler (m :: Type -> Type) a

-- | Always take the specified <a>Action</a>.
Simple :: Action -> Handler (m :: Type -> Type) a

-- | Allow inspection of the element, exception, and execution of monadic
--   actions before deciding the <a>Action</a> to take.
Handle :: (a -> SomeException -> m Action) -> Handler (m :: Type -> Type) a

-- | Map a monadic function over a <a>Foldable</a>, processing elements in
--   parallel.
--   
--   This function does <b>NOT</b> guarantee that elements are processed in
--   a deterministic order!
parMapM_ :: (Foldable f, MonadUnliftIO m) => Handler m a -> Int -> (a -> m ()) -> f a -> m ()

-- | Like <a>parMapM_</a>, but folds the individual results into single
--   result value.
--   
--   This function does <b>NOT</b> guarantee that elements are processed in
--   a deterministic order!
parFoldMap :: (Foldable f, MonadUnliftIO m) => Handler m a -> Int -> (a -> m b) -> (r -> b -> r) -> r -> f a -> m r

-- | Like <a>parFoldMap</a>, but uses a monadic fold function.
--   
--   This function does <b>NOT</b> guarantee that elements are processed in
--   a deterministic order!
parFoldMapM :: forall a b f m r. (Foldable f, MonadUnliftIO m) => Handler m a -> Int -> (a -> m b) -> (r -> b -> m r) -> r -> f a -> m r

-- | Strict fold of the <a>BroadcastChan</a>​'s messages. Can be used with
--   <a>Control.Foldl</a> from Tekmo's foldl package:
--   
--   <pre>
--   <a>Control.Foldl</a>.<a>purely</a> <a>foldBChan</a> :: (<a>MonadIO</a> m, <a>MonadIO</a> n) =&gt; <a>Fold</a> a b -&gt; <a>BroadcastChan</a> d a -&gt; n (m b)
--   </pre>
--   
--   The result of this function is a nested monadic value to give more
--   fine-grained control/separation between the start of listening for
--   messages and the start of processing. The inner action folds the
--   actual messages and completes when the channel is closed and
--   exhausted. The outer action controls from when on messages are
--   received. Specifically:
--   
--   <ul>
--   <li><i><a>BroadcastChan</a> <a>In</a>:</i> Will process all messages
--   sent after the outer action completes.</li>
--   <li><i><a>BroadcastChan</a> <a>Out</a>:</i> Will process all messages
--   that are unread when the outer action completes, as well as all future
--   messages.After the outer action completes the fold is unaffected by
--   other (concurrent) reads performed on the original channel. So it's
--   safe to reuse the channel.</li>
--   </ul>
foldBChan :: forall m n x a b (d :: Direction). (MonadIO m, MonadIO n) => (x -> a -> x) -> x -> (x -> b) -> BroadcastChan d a -> n (m b)

-- | Strict, monadic fold of the <a>BroadcastChan</a>​'s messages. Can be
--   used with <a>Control.Foldl</a> from Tekmo's foldl package:
--   
--   <pre>
--   <a>Control.Foldl</a>.<a>impurely</a> <a>foldBChanM</a> :: (<a>MonadIO</a> m, <a>MonadIO</a> n) =&gt; <a>FoldM</a> m a b -&gt; <a>BroadcastChan</a> d a -&gt; n (m b)
--   </pre>
--   
--   Has the same behaviour and guarantees as <a>foldBChan</a>.
foldBChanM :: forall m n x a b (d :: Direction). (MonadIO m, MonadIO n) => (x -> a -> m x) -> m x -> (x -> m b) -> BroadcastChan d a -> n (m b)
instance GHC.Classes.Eq BroadcastChan.Throw.BChanError
instance GHC.Internal.Exception.Type.Exception BroadcastChan.Throw.BChanError
instance GHC.Internal.Read.Read BroadcastChan.Throw.BChanError
instance GHC.Internal.Show.Show BroadcastChan.Throw.BChanError
