box-0.9.3.1: A profunctor effect system.
Safe HaskellSafe-Inferred
LanguageGHC2021

Box.Queue

Description

STM Queues, based originally on pipes-concurrency

Synopsis

Documentation

data Queue a Source #

Queue specifies how messages are queued

queueL :: Queue a -> (Committer IO a -> IO l) -> (Emitter IO a -> IO r) -> IO l Source #

Create an unbounded queue, returning the result from the Committer action.

queueR :: Queue a -> (Committer IO a -> IO l) -> (Emitter IO a -> IO r) -> IO r Source #

Create an unbounded queue, returning the result from the Emitter action.

queue :: Queue a -> (Committer IO a -> IO l) -> (Emitter IO a -> IO r) -> IO (l, r) Source #

Create an unbounded queue, returning both results.

>>> queue Unbounded (\c -> glue c <$|> qList [1..3]) toListM
((),[1,2,3])

fromAction :: (Box IO a b -> IO r) -> CoBox IO b a Source #

Turn a box action into a box continuation

emitQ :: Queue a -> (Committer IO a -> IO r) -> CoEmitter IO a Source #

Hook a committer action to a queue, creating an emitter continuation.

commitQ :: Queue a -> (Emitter IO a -> IO r) -> CoCommitter IO a Source #

Hook a committer action to a queue, creating an emitter continuation.

fromActionWith :: Queue a -> Queue b -> (Box IO a b -> IO r) -> CoBox IO b a Source #

Turn a box action into a box continuation

toBoxM :: Queue a -> IO (Box IO a a, IO ()) Source #

turn a queue into a box (and a seal), and lift from stm to the underlying monad.

toBoxSTM :: Queue a -> STM (Box STM a a, STM ()) Source #

turn a queue into a box (and a seal)

concurrentlyLeft :: IO a -> IO b -> IO a Source #

run two actions concurrently, but wait and return on the left result.

concurrentlyRight :: IO a -> IO b -> IO b Source #

run two actions concurrently, but wait and return on the right result.