network-stream-0.1.0: ByteString and Text streams for networking

Network.Text.Lazy.Stream

Description

Streams using Text by encoding in Utf 8.

Synopsis

Documentation

data Result a Source

Represents whether the stream transaction was a success or a failure; nothing is done by the library with the attached value. If you do not need to send back a value to the caller of withStream, you can use a Result ().

Constructors

Success a 
Failure a 

Instances

Read a => Read (Result a) 
Show a => Show (Result a) 

data Stream Source

The core data type for a Stream. It can only be created using withStream.

invalidate :: Stream -> IO ()Source

Doesn't fail, but tells the client that all the data sent by the stream so far has been invalidated, and hence the queue of messages to be sent is cleared.

withStream :: Handle -> (Stream -> IO (Result a)) -> IO aSource

Opens a stream using the given handle and passes it to the function, and then unwraps the result given and gives any user data that the specific function wants to give back.

write :: Stream -> Text -> IO ()Source

Writes partial or full data over a Stream, placing it in the queue of data to be sent. Encodes the Text with Utf8 into a strict Data.ByteString.Lazy.ByteString.

receiveE :: MonadIO m => Handle -> Iteratee Text m b -> m (Maybe b)Source

Receives the entire data should the transfer over the stream be successful. Returns Nothing on failure.

Run an iteratee through an enumerator which supplies each block of Text.