The lazy ByteString type and representation
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.
Empty :: ByteString
Chunk :: S.StrictByteString -> ByteString -> 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.
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
The chunk size used for I/O. Currently set to 32k, less the memory management overhead
The recommended chunk size. Currently set to 4k, less the memory management overhead
The memory management overhead. Currently this is tuned for GHC only.
Conversion with lists: packing and unpacking
packBytes :: [Word8] -> ByteString
packChars :: [Char] -> ByteString
unpackBytes :: ByteString -> [Word8]
unpackChars :: ByteString -> [Char]
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 ByteStringinstance Eq ByteStringinstance Ord ByteStringinstance Semigroup ByteStringinstance Monoid ByteStringinstance NFData ByteStringinstance Show ByteStringinstance Read ByteStringinstance IsList ByteStringinstance IsString ByteStringBeware: 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