mutable-iter-0.6: iteratees based upon mutable buffers




data IOBuffer r el Source

A mutable buffer to hold storable elements. This data type supports memory recycling.


createIOBuffer :: Storable el => Int -> ForeignPtr Int -> ForeignPtr el -> IOBuffer r elSource

Create a buffer from a length and data array.

null :: IOBuffer r el -> IO BoolSource

Check if the buffer is empty.

empty :: Storable el => IOBuffer r elSource

Empty buffer.

copyBuffer :: Storable el => IOBuffer r el -> IO (IOBuffer r el)Source

Copy data from one buffer to another.

append :: Storable el => IOBuffer r el -> IOBuffer r el -> IO (IOBuffer r el)Source

Append two buffers. Copies data from both into a new buffer.

length :: IOBuffer r el -> IO IntSource

IOBuffer length.

pop :: Storable el => IOBuffer r el -> IO elSource

Retrieve the front element from the buffer and advance the internal pointer. It is an error to call this on an empty buffer.

lookAtHead :: Storable el => IOBuffer r el -> IO (Maybe el)Source

Retrieve the first element, if it exists. This function does not advance the buffer pointer.

drop :: Int -> IOBuffer r el -> IO ()Source

Drop n elements from the front of the buffer. if the buffer has fewer elements, all are dropped.

dropWhile :: Storable el => (el -> Bool) -> IOBuffer r el -> IO ()Source

take :: Storable el => IOBuffer r el -> Int -> IO (IOBuffer r el)Source

Create a new buffer from the first n elements, sharing data. This function advances the pointer of the original buffer.

splitAt :: Storable el => IOBuffer r el -> Int -> IO (IOBuffer r el, IOBuffer r el)Source

Split one buffer to two, sharing storage.

mapBuffer :: (Storable el, Storable el') => (el -> el') -> ForeignPtr Int -> ForeignPtr el' -> IOBuffer r el -> IO (IOBuffer r el')Source

copy data from one buffer to another with the specified map function. this operation drains the original buffer.

mapAccumBuffer :: (Storable el, Storable el') => (acc -> el -> (acc, el')) -> ForeignPtr Int -> ForeignPtr el' -> acc -> IOBuffer r el -> IO (acc, IOBuffer r el')Source

foldl' :: Storable b => (a -> b -> a) -> a -> IOBuffer r b -> IO aSource

castBuffer :: forall r m el el'. (Storable el, Storable el') => IOBuffer r el -> IO (IOBuffer r el')Source

Cast a buffer to a different type. Any extra data is truncated. This is not safe unless the buffer offset is 0.

freeze :: (Storable el, Vector v el, Vector v Int) => IOBuffer r el -> IO (v el)Source

Safely convert an IOBuffer to a Vector.

thaw :: (Storable el, Vector v el) => v el -> IO (IOBuffer r el)Source

Safely convert a Vector to an IOBuffer

hPut :: forall r el. Storable el => Handle -> IOBuffer r el -> IO ()Source

Write out the contents of the IOBuffer to a handle. This operation drains the buffer.