io-streams-1.5.2.2: Simple, composable, and easy-to-use stream I/O
Safe HaskellNone
LanguageHaskell2010

System.IO.Streams.Concurrent

Description

Stream utilities for working with concurrent channels.

Synopsis

Channel conversions

inputToChan :: InputStream a -> Chan (Maybe a) -> IO () Source #

Writes the contents of an input stream to a channel until the input stream yields end-of-stream.

chanToInput :: Chan (Maybe a) -> IO (InputStream a) Source #

Turns a Chan into an input stream.

chanToOutput :: Chan (Maybe a) -> IO (OutputStream a) Source #

Turns a Chan into an output stream.

concurrentMerge :: [InputStream a] -> IO (InputStream a) Source #

Concurrently merges a list of InputStreams, combining values in the order they become available.

Note: does not forward individual end-of-stream notifications, the produced stream does not yield end-of-stream until all of the input streams have finished.

Any exceptions raised in one of the worker threads will be trapped and re-raised in the current thread.

If the supplied list is empty, concurrentMerge will return an empty stream. (Since: 1.5.0.1)

makeChanPipe :: IO (InputStream a, OutputStream a) Source #

Create a new pair of streams using an underlying Chan. Everything written to the OutputStream will appear as-is on the InputStream.

Since reading from the InputStream and writing to the OutputStream are blocking calls, be sure to do so in different threads.