Efficient buffered output.

Version on this page:
LTS Haskell 8.2:
Stackage Nightly 2017-02-22:
Latest on Hackage:
BSD3 licensed by Jasper Van der Jeugt, Simon Meier, Leon P Smith


Continuous Integration status Hackage page (downloads and API reference)

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.


- Fixed warnings on GHC 7.10, courtesy of Mikhail Glushenkov.

- Tightened the version constraints on the bytestring package for GHC 7.8

- This is now a compatibility shim for the new bytestring builder. Most
of the old internal modules are gone. See this blog post for more


- The 'Blaze.ByteString.Builder.Html.Utf8.fromHtmlEscaped*' functions now
strip out any ASCII control characters present in their inputs. See
<> for more

- exposed the 'Buffer' constructor to enable keeping around a pool of

- added 'writeToByteString' to construct a strict bytestring in a single
step. We can actually view 'Write's as strict-bytestring builders.

- Changed imports of Foreign.Unsafe to make it GHC 7.8 compatible
- -Wall clean on GHC 7.0 - 7.6

- Widened dependencies on text and bytestring


- Fix build warning in Blaze.ByteString.Builder.Word
(contributed by Greg Weber)


- Remove comparison to the 'text' library encoding functions of
'Blaze.Builder.Char.Utf8.fromText' and
'Blaze.Builder.Char.Utf8.fromLazyText'. Bryan O'Sullivan reported that on
his 64-bit system with GHC 7.0.3 the 'text' library is 5x faster than the
'blaze-builder' library.


- Renamings in internal modules: WriteIO -> Poke and associated functions.


- Fixed bug: appending to 'chunkedTransferEncoding somebuilder' also encoded
the appended builder, which is obviously wrong.


- Fixed bug: 'chunkedTransferTerminator' is now correctly set to "0\r\n\r\n".


- Add 'MonoPatBinds' language extension to all relevant files to solve the
issues caused by GHC bug


- Reexport 'Write' datatype and 'fromWriteList', 'fromWriteSingleton',
'fromWrite' functions together with writes and builders for storables.
- Add 'MonoPatBinds' language extension to (hopefully) solve the issues
caused by GHC bug


Incorporated several design changes:
- Writable buffer range is now represented in a packed form. This improves
speed slightly, as less currying is used.
- Writes are abstracted such that their internal representation can be
exchanged without breaking other library code.
- Writes are represented in a form that allows for efficient monoid
instances for branching code like UTF-8 encoding. For single character
encoding this results currently in a slight slowdown due to GHC not
recognizing the strictness of the returned value. This will be fixed in
the future.
- BuildSteps support returning a result in `Done`, which enables to
implement a `Put` monad using CPS.
- chunked list writes were removed, as they result in worse performance
when writing non-trivial lists. (cf. benchmarks)
- An internal buffering abstraction is introduced, which is used both
by the adaption of the `binary` package, as well as by the
`blaze-builder-enumeratee` package, to execute puts and builders.
It will be used later also by the execution functions of the
`blaze-builder` package.

Implemented new functionality
- `Blaze.ByteString.Builder.HTTP` provides a builder transformer for
doing in-buffer chunked HTTP encoding of an arbitary other builder.
- `Blaze.ByteString.Builder.Char8` provides functions to serialize the
lower 8-bits of characters similiar to what `Data.ByteString.Char8`
provides for bytestrings.


Loosen 'text' dependency to '>= 0.10 && < 0.12'


Fixed bug: use &#39; instead of &apos; for HTML escaping '


Added a missing benchmark file.

* blaze-builder-

Heavily restructured 'blaze-builder' such that 'Blaze.ByteString.Builder' serves as
a drop-in replacement of 'binary:Data.Binary.Builder' which it improves upon
with respect to both speed as well as expressivity. See the documentation and
the benchmarks for details on improvements and new functionality.

Changed module structure:
Blaze.ByteString.Builder.Core -> Blaze.ByteString.Builder
Blaze.ByteString.Builder.Utf8 -> Blaze.ByteString.Builder.Char.Utf8
Blaze.ByteString.Builder.Html -> Blaze.ByteString.Builder.Html.Utf8

Changed function names:
writeByte -> writeWord8
fromByte -> fromWord8
fromWriteList -> fromWrite1List

Possibly performance sensitive implementation changes:
- 'fromByteString' and 'fromLazyByteString' check now if a direct insertion
of the bytestring(s) would be cheaper than copying it. See their
documentation on how to recover the old behaviour.

Deprecated functions:
'empty' : use 'mempty' instead
'singleton': use 'fromWord8' instead
'append' : use 'mappend' instead

* blaze-builder-0.1

This is the first version of 'blaze-builder'. It is explicitely targeted at
fast generation of UTF-8 encoded HTML documents in the 'blaze-html' and the
'hamlet' HTML templating libraries.
Depends on:
Used by 244 packages:
AttoBencode, CurryDB, FastxPipe, HStringTemplate, HongoDB, StrappedTemplates, Wheb, Yablog, aeson-native, airship, apiary, apiary-authenticate, apiary-cookie, apiary-eventsource, arx, ascii, atom-conduit, atto-lisp, authenticate, authenticate-oauth, aws, aws-ec2, aws-general, aws-kinesis, aws-sign4, aws-simple, aws-sns, beamable, biostockholm, blaze-builder-enumerator, blaze-html, blaze-markup, blaze-textual, blaze-textual-native, blazeT, bloodhound, bugzilla, cake3, cascading, cassava, cerberus, conduit-extra, convertible-ascii, cookie, corebot-bliki, couchdb-conduit, cqrs-example, csv-conduit, d-bus, darcsden, digestive-functors-heist, dingo-core, docker, domain-auth, dropbox-sdk, dtd, dynamic-pp, eventsourced, ez-couch, flowdock-api, fn, fn-extra, freesound, gc-monitoring-wai, geo-resolver, git-annex, groundhog, groundhog-postgresql, growler, hack2-handler-mongrel2-http, hack2-handler-snap-server, hackage-proxy, hackage-server, haggis, hails, happstack-heist, haskell-aliyun, hastache, haste-compiler, haxr, hbeanstalk, hdbi, hdbi-postgresql, hdbi-sqlite, heist, heist-aeson, helix, hipbot, hjsmin, hoodle-builder, hoovie, hosc, hpaste, hslogstash, http-client, http-client-auth, http-common, http-enumerator, http-pony-serve-wai, http-proxy, http-reverse-proxy, http-streams, http-types, hums, implicit, json-builder, json-enumerator, json2, keter, language-javascript, lendingclub, ltiv1p1, lucid, lucid-svg, mangopay, memcache, mighttpd2, miku, mime-mail, monad-logger, mongrel2-handler, msgpack, msgpack-idl, musicbrainz-email, mustache2hs, mysql-simple, notmuch-web, oauthenticated, objectid, persistent-mysql, persistent-postgresql, pg-store, pgsql-simple, pgstream, pipes-csv, pipes-wai, planar-graph, plivo, postgresql-orm, postgresql-query, prefork, quandl-api, req, restful-snap, riak, ripple-federation, roundtrip-xml, rpf, rtorrent-rpc, scalable-server, scotty, scotty-blaze, scotty-cookie, scotty-session, seacat, servant-auth-cookie, servant-auth-server, servant-subscriber, servius, simple, simple-session, sjsp, smtlib2-pipe, snap-extras, snap-routes, snap-server, snaplet-actionlog, snaplet-recaptcha, snaplet-rest, snaplet-wordpress, socketio, sproxy2, sqlite-simple, sssp, stable-tree, stack, stm-firehose, streaming-commons, svg-builder, tag-stream, tagstream-conduit, tamarin-prover, tamarin-prover-utils, tempodb, time-http, tkyprof, trifecta, twentefp-websockets, uri-bytestring, vaultaire-common, vigilance, vty, wai, wai-app-file-cgi, wai-app-static, wai-conduit, wai-extra, wai-handler-launch, wai-logger, wai-middleware-auth, wai-middleware-caching, wai-middleware-caching-lru, wai-middleware-caching-redis, wai-middleware-content-type, wai-middleware-crowd, wai-routes, wai-session, wai-session-alt, wai-static-pages, wai-thrift, wai-util, wai-websockets, warp, web-page, web-routes, webapi, webapp, webcrank, webify, websockets, webwire, welshy, wrecker, xml-conduit, xml-enumerator, xml2json, xmlgen, xmlhtml, xournal-builder, yackage, yesod-auth, yesod-bin, yesod-content-pdf, yesod-core, yesod-eventsource, yesod-form, yesod-form-richtext, yesod-persistent, yesod-platform, yesod-static, yesod-static-angular, yesod-test, zoom-cache, zoom-cache-pcm
comments powered byDisqus