BSD-3-Clause licensed by Jasper Van der Jeugt, Simon Meier
Maintained by Simon Meier
This version can be pinned in stack with:blaze-builder-0.3.3.4@sha256:ca3ff6566fd31dafb097b826a2503aed2098b06d31edc95ded262063c0fd8003,2945

Module documentation for 0.3.3.4

  • Blaze
    • Blaze.ByteString
      • Blaze.ByteString.Builder
        • Blaze.ByteString.Builder.ByteString
        • Blaze.ByteString.Builder.Char
          • Blaze.ByteString.Builder.Char.Utf8
        • Blaze.ByteString.Builder.Char8
        • Blaze.ByteString.Builder.HTTP
        • Blaze.ByteString.Builder.Html
          • Blaze.ByteString.Builder.Html.Utf8
        • Blaze.ByteString.Builder.Int
        • Blaze.ByteString.Builder.Internal
          • Blaze.ByteString.Builder.Internal.Buffer
          • Blaze.ByteString.Builder.Internal.Types
          • Blaze.ByteString.Builder.Internal.Write
        • Blaze.ByteString.Builder.Word

blaze-builder

This library allows to efficiently serialize Haskell values to lazy bytestrings with a large average chunk size. The large average chunk size allows to make good use of cache prefetching in later processing steps (e.g. compression) and reduces the system call overhead when writing the resulting lazy bytestring to a file or sending it over the network.

This library was inspired by the module Data.Binary.Builder provided by the binary package. It was originally developed with the specific needs of the blaze-html package in mind. Since then it has been restructured to serve as a drop-in replacement for Data.Binary.Builder, which it improves upon both in speed as well as expressivity.

To see the improvements in speed, run the throughput benchmark, which measures serialization speeds for writing Word8, Word16, Word32 and Word64 in different endian formats and different chunk sizes, using the command

make bench-throughput

or run the list serialization comparison benchmark

make bench-blaze-vs-binary

Checkout the combinators in the module “Blaze.ByteString.Builder.Write” to see the improvements in expressivity. This module allows to incorporate efficient primitive buffer manipulations as parts of a builder. We use this facility in the ‘blaze-html’ HTML templating library to allow for the efficient serialization of HTML escaped and UTF-8 encoded characters.