Data.ByteString.Lazy.Internal

bytestring-0.10.12.1: Fast, compact, strict and lazy byte strings with a list interface

Copyright | (c) Don Stewart 2006-2008 (c) Duncan Coutts 2006-2011
License | BSD-style
Maintainer | dons00@gmail.com, duncan@community.haskell.org
Stability | unstable
Portability | non-portable
Safe Haskell | Unsafe
Language | Haskell98

Data.ByteString.Lazy.Internal

Contents

- The lazy `ByteString` type and representation
- Data type invariant and abstraction function
- Chunk allocation sizes
- Conversion with lists: packing and unpacking

Description

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.

Synopsis

- data ByteString
  - = Empty
  - | Chunk !ByteString ByteString
- chunk :: ByteString -> ByteString -> ByteString
- foldrChunks :: (ByteString -> a -> a) -> a -> ByteString -> a
- foldlChunks :: (a -> ByteString -> a) -> a -> ByteString -> a
- invariant :: ByteString -> Bool
- checkInvariant :: ByteString -> ByteString
- defaultChunkSize :: Int
- smallChunkSize :: Int
- chunkOverhead :: Int
- packBytes :: [Word8] -> ByteString
- packChars :: [Char] -> ByteString
- unpackBytes :: ByteString -> [Word8]
- unpackChars :: ByteString -> [Char]

# The lazy `ByteString` type and representation

data ByteString Source #

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

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

Constructors

Empty |
Chunk !ByteString ByteString |

#### Instances

Instances details

Data ByteString Source # |
Instance details Defined in Data.ByteString.Lazy.Internal Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ByteString -> c ByteString Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ByteString Source # toConstr :: ByteString -> Constr Source # dataTypeOf :: ByteString -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ByteString) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ByteString) Source # gmapT :: (forall b. Data b => b -> b) -> ByteString -> ByteString Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ByteString -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ByteString -> r Source # gmapQ :: (forall d. Data d => d -> u) -> ByteString -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> ByteString -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ByteString -> m ByteString Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ByteString -> m ByteString Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ByteString -> m ByteString Source #
IsString ByteString Source # | Beware: `fromString` truncates multi-byte characters to octets. e.g. "枯朶に烏のとまりけり秋の暮" becomes �6k�nh~�Q��n�
Instance details Defined in Data.ByteString.Lazy.Internal Methods fromString :: String -> ByteString Source #
Monoid ByteString Source # |
Instance details Defined in Data.ByteString.Lazy.Internal Methods mempty :: ByteString Source # mappend :: ByteString -> ByteString -> ByteString Source # mconcat :: [ByteString] -> ByteString Source #
Semigroup ByteString Source # |
Instance details Defined in Data.ByteString.Lazy.Internal Methods (<>) :: ByteString -> ByteString -> ByteString Source # sconcat :: NonEmpty ByteString -> ByteString Source # stimes :: Integral b => b -> ByteString -> ByteString Source #
IsList ByteString Source # | Since: bytestring-0.10.12.0
Instance details Defined in Data.ByteString.Lazy.Internal Associated Types type Item ByteString Source # Methods fromList :: [Item ByteString] -> ByteString Source # fromListN :: Int -> [Item ByteString] -> ByteString Source # toList :: ByteString -> [Item ByteString] Source #
Read ByteString Source # |
Instance details Defined in Data.ByteString.Lazy.Internal Methods readsPrec :: Int -> ReadS ByteString Source # readList :: ReadS [ByteString] Source # readPrec :: ReadPrec ByteString Source # readListPrec :: ReadPrec [ByteString] Source #
Show ByteString Source # |
Instance details Defined in Data.ByteString.Lazy.Internal Methods showsPrec :: Int -> ByteString -> ShowS Source # show :: ByteString -> String Source # showList :: [ByteString] -> ShowS Source #
NFData ByteString Source # |
Instance details Defined in Data.ByteString.Lazy.Internal Methods rnf :: ByteString -> () Source #
Eq ByteString Source # |
Instance details Defined in Data.ByteString.Lazy.Internal Methods (==) :: ByteString -> ByteString -> Bool Source # (/=) :: ByteString -> ByteString -> Bool Source #
Ord ByteString Source # |
Instance details Defined in Data.ByteString.Lazy.Internal Methods compare :: ByteString -> ByteString -> Ordering Source # (<) :: ByteString -> ByteString -> Bool Source # (<=) :: ByteString -> ByteString -> Bool Source # (>) :: ByteString -> ByteString -> Bool Source # (>=) :: ByteString -> ByteString -> Bool Source # max :: ByteString -> ByteString -> ByteString Source # min :: ByteString -> ByteString -> ByteString Source #
type Item ByteString Source # |
Instance details Defined in Data.ByteString.Lazy.Internal type Item ByteString = Word8

chunk :: ByteString -> ByteString -> ByteString Source #

Smart constructor for `Chunk`. Guarantees the data type invariant.

foldrChunks :: (ByteString -> a -> a) -> a -> ByteString -> a Source #

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

foldlChunks :: (a -> ByteString -> a) -> a -> ByteString -> a Source #

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

# Data type invariant and abstraction function

invariant :: ByteString -> Bool Source #

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

checkInvariant :: ByteString -> ByteString Source #

In a form that checks the invariant lazily.

# Chunk allocation sizes

defaultChunkSize :: Int Source #

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

smallChunkSize :: Int Source #

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

chunkOverhead :: Int Source #

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

# Conversion with lists: packing and unpacking

packBytes :: [Word8] -> ByteString Source #

packChars :: [Char] -> ByteString Source #

unpackBytes :: ByteString -> [Word8] Source #

unpackChars :: ByteString -> [Char] Source #