io-streams-1.2.1.1: Simple, composable, and easy-to-use stream I/O

Safe HaskellTrustworthy
LanguageHaskell2010

System.IO.Streams.Handle

Contents

Description

Input and output streams for file Handles.

Synopsis

Handle conversions

handleToInputStream :: Handle -> IO (InputStream ByteString) Source

Converts a read-only handle into an InputStream of strict ByteStrings.

Note that the wrapped handle is not closed when it yields end-of-stream; you can use atEndOfInput to close the handle if you would like this behaviour.

handleToOutputStream :: Handle -> IO (OutputStream ByteString) Source

Converts a writable handle into an OutputStream of strict ByteStrings.

Note that the wrapped handle is not closed when it receives end-of-stream; you can use atEndOfOutput to close the handle if you would like this behaviour.

Note: to force the Handle to be flushed, you can write a null string to the returned OutputStream:

Streams.write (Just "") os

inputStreamToHandle :: InputStream ByteString -> IO Handle Source

Converts an InputStream over bytestrings to a read-only Handle. Note that the generated handle is opened unbuffered in binary mode (i.e. no newline translation is performed).

Note: the InputStream passed into this function is wrapped in lockingInputStream to make it thread-safe.

Since: 1.0.2.0.

outputStreamToHandle :: OutputStream ByteString -> IO Handle Source

Converts an OutputStream over bytestrings to a write-only Handle. Note that the Handle will be opened in non-buffering mode; if you buffer the OutputStream using the Handle buffering then io-streams will copy the Handle buffer when sending ByteString values to the output, which might not be what you want.

When the output buffer, if used, is flushed (using hFlush), an empty string is written to the provided OutputStream.

Note: the OutputStream passed into this function is wrapped in lockingOutputStream to make it thread-safe.

Since: 1.0.2.0.

streamPairToHandle :: InputStream ByteString -> OutputStream ByteString -> IO Handle Source

Converts a pair of InputStream and OutputStream over bytestrings to a read-write Handle.

Note: the streams passed into this function are wrapped in locking primitives to make them thread-safe.

Since: 1.0.2.0.

Standard system handles