The bytestring package

[Tags: bsd3, library]

An efficient compact, immutable byte string type (both strict and lazy) suitable for binary or 8-bit character data.

The ByteString type represents sequences of bytes or 8-bit characters. It is suitable for high performance use, both in terms of large data quantities, or high speed requirements. The ByteString functions follow the same style as Haskell's ordinary lists, so it is easy to convert code from using String to ByteString.

Two ByteString variants are provided:

The Char8 modules provide a character-based view of the same underlying ByteString types. This makes it convenient to handle mixed binary and 8-bit character content (which is common in many file formats and network protocols).

The Builder module provides an efficient way to build up ByteStrings in an ad-hoc way by repeated concatenation. This is ideal for fast serialisation or pretty printing.

There is also a ShortByteString type which has a lower memory overhead and can can be converted to or from a ByteString, but supports very few other operations. It is suitable for keeping many short strings in memory.

ByteStrings are not designed for Unicode. For Unicode strings you should use the Text type from the text package.

These modules are intended to be imported qualified, to avoid name clashes with Prelude functions, e.g.

 import qualified Data.ByteString as BS

[Skip to ReadMe]


Dependenciesbase (>=4.2 && <5), deepseq, ghc-prim, integer (==0.1.*), integer-gmp (>=0.2) [details]
CopyrightCopyright (c) Don Stewart 2005-2009, (c) Duncan Coutts 2006-2015, (c) David Roundy 2003-2005, (c) Jasper Van der Jeugt 2010, (c) Simon Meier 2010-2013.
AuthorDon Stewart, Duncan Coutts
MaintainerDuncan Coutts <>
Home page
Bug tracker
Source repositoryhead: git clone
UploadedMon Mar 23 11:08:06 UTC 2015 by DuncanCoutts
DistributionsFedora:, LTSHaskell:, NixOS:, Stackage:
Downloads36411 total (180 in last 30 days)
2 []
StatusDocs available [build log]
Last success reported on 2015-03-23 [all 1 reports]




integer-simpleUse the simple integer library instead of GMPDisabledAutomatic

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Maintainers' corner

For package maintainers and hackage trustees

Readme for bytestring-

ByteString: Fast, Packed Strings of Bytes

Build Status

This library provides the Data.ByteString module -- strict and lazy byte arrays manipulable as strings -- providing very time/space-efficient string and IO operations.

For very large data requirements, or constraints on heap size, Data.ByteString.Lazy is provided, a lazy list of bytestring chunks. Efficient processing of multi-gigabyte data can be achieved this way.

The library also provides Data.ByteString.Builder for efficient construction of ByteString values from smaller pieces during binary serialization.



cabal install

You can run the testsuite as follows:

cabal test


ByteString was derived from the GHC PackedString library, originally written by Bryan O'Sullivan, and then by Simon Marlow. It was adapted and greatly extended for darcs by David Roundy and others. Don Stewart and Duncan Coutts cleaned up and further extended the implementation and added the .Lazy code. Simon Meier contributed the Builder feature.