vector-bytestring- ByteStrings as type synonyms of Storable Vectors of Word8s

MaintainerBas van Dijk <>
Safe HaskellUnsafe




A module containing semi-public ByteString internals. This exposes the ByteString representation and low level construction functions. Modules which extend the ByteString system will need to use this module while ideally most users will be able to make do with the public interface modules.


The lazy ByteString type and representation

data ByteString Source

A space-efficient representation of a Word8 vector, supporting many efficient operations. A ByteString contains 8-bit characters only.

Instances of Eq, Ord, Read, Show, Data, Typeable

chunk :: ByteString -> ByteString -> ByteStringSource

Smart constructor for Chunk. Guarantees the data type invariant.

foldrChunks :: (ByteString -> a -> a) -> a -> ByteString -> aSource

Consume the chunks of a lazy ByteString with a natural right fold.

foldlChunks :: (a -> ByteString -> a) -> a -> ByteString -> aSource

Consume the chunks of a lazy ByteString with a strict, tail-recursive, accumulating left fold.

Data type invariant and abstraction function

invariant :: ByteString -> BoolSource

The data type invariant: Every ByteString is either Empty or consists of non-null ByteStrings. All functions must preserve this, and the QC properties must check this.

checkInvariant :: ByteString -> ByteStringSource

In a form that checks the invariant lazily.

Chunk allocation sizes

defaultChunkSize :: IntSource

Currently set to 32k, less the memory management overhead

smallChunkSize :: IntSource

Currently set to 4k, less the memory management overhead

chunkOverhead :: IntSource

The memory management overhead. Currently this is tuned for GHC only.