Community
Modules 15

Data.ByteString.Lazy.Internal

unstable

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

A space-efficient representation of a Word8 vector, supporting many efficient operations.

A LazyByteString contains 8-bit bytes, or by using the operations from Data.ByteString.Lazy.Char8 it can be interpreted as containing 8-bit characters.

Chunk :: S.StrictByteString -> ByteString -> ByteString

type LazyByteString = ByteString

Type synonym for the lazy flavour of ByteString.

chunk :: S.StrictByteString -> ByteString -> ByteString

Smart constructor for Chunk. Guarantees the data type invariant.

foldrChunks :: (S.StrictByteString -> a -> a) -> a -> ByteString -> a

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

foldlChunks :: (a -> S.StrictByteString -> a) -> a -> ByteString -> a

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

Data type invariant and abstraction function

invariant :: ByteString -> Bool

The data type invariant: Every ByteString is either Empty or consists of non-null StrictByteStrings. All functions must preserve this.

checkInvariant :: ByteString -> ByteString

Lazily checks that the given ByteString satisfies the data type's "no empty chunks" invariant, raising an exception in place of the first chunk that does not satisfy the invariant.

Chunk allocation sizes

defaultChunkSize :: Int

The chunk size used for I/O. Currently set to 32k, less the memory management overhead

smallChunkSize :: Int

The recommended chunk size. Currently set to 4k, less the memory management overhead

chunkOverhead :: Int

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

Conversion with lists: packing and unpacking

Conversions with strict ByteString

fromStrict :: S.StrictByteString -> LazyByteString

O(1) Convert a StrictByteString into a LazyByteString.

toStrict :: LazyByteString -> S.StrictByteString

O(n) Convert a LazyByteString into a StrictByteString.

Note that this is an expensive operation that forces the whole LazyByteString into memory and then copies all the data. If possible, try to avoid converting back and forth between strict and lazy bytestrings.

Instances

11
  • instance TH.Lift ByteString
  • instance Eq ByteString
  • instance Ord ByteString
  • instance Semigroup ByteString
  • instance Monoid ByteString
  • instance NFData ByteString
  • instance Show ByteString
  • instance Read ByteString
  • instance IsList ByteString
  • instance IsString ByteString

    Beware: fromString truncates multi-byte characters to octets. e.g. "枯朶に烏のとまりけり秋の暮" becomes �6k�nh~�Q��n�

  • instance Data ByteString
Maintainer
dons00@gmail.com, duncan@community.haskell.org
Portability
non-portable
Copyright
(c) Don Stewart 2006-2008 (c) Duncan Coutts 2006-2011
License
BSD-style
Build record and source files

Community contribution. The service has not verified this documentation. The generator reported 11 diagnostics.

Target: Linux on x86-64. Some inferred types and resolved links are not available.

Generator: aihc-haddock-aa6debbd-web-3

Metadata snapshot: 35f1f56d3dce7f0c7af322ec05f2fba4d1a04564930537462a4ba21b64b756fa

Open the dependency plan · Download the documentation model

Import a package

Enter a package name and an exact version from Hackage. The site contains imported versions only.