HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleblaze-builder-0.4.4.1Haskell98

Blaze.ByteString.Builder.ByteString

Writes and Builders for strict and lazy bytestrings.

We assume the following qualified imports in order to differentiate between strict and lazy bytestrings in the code examples.

import qualified Data.ByteString      as S
import qualified Data.ByteString.Lazy as L
  • 9 values

Strict bytestrings

5 declarations
valuefromByteStringWith
  1. :: Int

    Maximal number of bytes to copy.

  2. -> ByteString

    Strict ByteString to serialize.

  3. -> Builder

    Resulting Builder.

#

Construct a Builder that copies the strict ByteStrings, if it is smaller than the threshold, and inserts it directly otherwise.

For example, fromByteStringWith 1024 copies strict ByteStrings whose size is less or equal to 1kb, and inserts them directly otherwise. This implies that the average chunk-size of the generated lazy ByteString may be as low as 513 bytes, as there could always be just a single byte between the directly inserted 1025 byte, strict ByteStrings.

Lazy bytestrings

4 declarations