enumerator-0.4.5: Reliable, high-performance processing with left-fold enumerators

Portabilityportable
Maintainerjmillikin@gmail.com

Data.Enumerator.Binary

Contents

Description

This module is intended to be imported qualified:

 import qualified Data.Enumerator.Binary as EB

Since: 0.4.5

Synopsis

Binary IO

enumHandleSource

Arguments

:: MonadIO m 
=> Integer

Buffer size

-> Handle 
-> Enumerator ByteString m b 

Read bytes (in chunks of the given buffer size) from the handle, and stream them to an Iteratee. If an exception occurs during file IO, enumeration will stop and Error will be returned. Exceptions from the iteratee are not caught.

This enumerator blocks until at least one byte is available from the handle, and might read less than the maximum buffer size in some cases.

The handle should be opened with no encoding, and in ReadMode or ReadWriteMode.

enumFile :: FilePath -> Enumerator ByteString IO bSource

Opens a file path in binary mode, and passes the handle to enumHandle. The file will be closed when the Iteratee finishes.

iterHandle :: MonadIO m => Handle -> Iteratee ByteString m ()Source

Read bytes from a stream and write them to a handle. If an exception occurs during file IO, enumeration will stop and Error will be returned.

The handle should be opened with no encoding, and in WriteMode or ReadWriteMode.

List analogues

head :: Monad m => Iteratee ByteString m (Maybe Word8)Source

Get the next byte from the stream, or Nothing if the stream has ended.

Since: 0.4.5

drop :: Monad m => Integer -> Iteratee ByteString m ()Source

drop n ignores n bytes of input from the stream.

Since: 0.4.5

dropWhile :: Monad m => (Word8 -> Bool) -> Iteratee ByteString m ()Source

dropWhile p ignores input from the stream until the first byte which does not match the predicate.

Since: 0.4.5

take :: Monad m => Integer -> Iteratee ByteString m ByteStringSource

take n extracts the next n bytes from the stream, as a lazy ByteString.

Since: 0.4.5

takeWhile :: Monad m => (Word8 -> Bool) -> Iteratee ByteString m ByteStringSource

takeWhile p extracts input from the stream until the first byte which does not match the predicate.

Since: 0.4.5

consume :: Monad m => Iteratee ByteString m ByteStringSource

Read all remaining input from the stream, and return as a lazy ByteString.

Since: 0.4.5

require :: Monad m => Integer -> Iteratee ByteString m ()Source

require n buffers input until at least n bytes are available, or throws an error if the stream ends early.

Since: 0.4.5

isolate :: Monad m => Integer -> Enumeratee ByteString ByteString m bSource

isolate n reads at most n bytes from the stream, and passes them to its iteratee. If the iteratee finishes early, bytes continue to be consumed from the outer stream until n have been consumed.

Since: 0.4.5