Bindings to libbz2

Version on this page:
LTS Haskell 22.29:
Stackage Nightly 2024-07-19:
Latest on Hackage:

See all snapshots bz2 appears in

BSD-3-Clause licensed by Vanessa McHale
Maintained by [email protected]
This version can be pinned in stack with:bz2-,3992

Module documentation for

Depends on 2 packages(full list with versions):
Used by 2 packages in lts-18.6(full list with versions):


High-level bindings to bzip2.


Compared to bzlib:

  • Bundles bzip2 1.0.8.
  • Compatible with GHC 8.8+
  • Uses c2hs rather than hsc2hs and thus has a larger dependency footprint

Unlike pipes-bzip and bzlib-conduit, bz2 can be cross-compiled.

Backpack Integration

bz2 implements bzip-signature, which makes it interchangeable with bzlib.



  • Add decompressErr

  • Fix bug decompressing partial data

  • Change buffering parameters for speed
  • Add benchmarks relative to bzlib, bzip-pipes, bzlib-conduit

  • Pass -O3 to cc-options

  • Remove Codec.Compression.BZip.Foreign
  • Use ForeignPtr under the hood
  • Lazier streaming; memory use should be sensible

  • Use ForeignPtrs under the hood in various places (over bracket)

  • Haddock improvements

  • Change type signature of bZ2BzlibVersion
  • Add Codec.Compression.BZip module

  • Fix distribution

Initial release