Various bit twiddling and bitwise serialization primitives

Version on this page:0.6
LTS Haskell 19.13:0.6@rev:1
Stackage Nightly 2022-06-26:0.6@rev:1
Latest on Hackage:0.6@rev:1

See all snapshots bits appears in

BSD-3-Clause licensed by Edward A. Kmett
Maintained by Edward A. Kmett
This version can be pinned in stack with:bits-0.6@sha256:57ac6c1c6ede20096357ce4a8d14a54a3ada984b934d10bb371af18becbb1288,1496

Module documentation for 0.6

Used by 3 packages in nightly-2022-01-27(full list with versions):


Hackage Build Status

This package provides a number of tools that are useful for dealing with files or data on a bitwise basis.

Contact Information

Contributions and bug reports are welcome!

Please feel free to contact me through github or on the #haskell IRC channel on

-Edward Kmett


0.6 [2021.11.07]

  • Allow building with GHC 9.2.1.
  • The Data.Bits.Extras.oneBits function now matches the implementation of the oneBits function from base’s Data.Bits module. This is a breaking change since the constraint has been strengthened from Bits to FiniteBits. If you need to invoke oneBits on a data type that does not have a FiniteBits instance (e.g., Integer), use the newly added unsafeOneBits function instead.
  • Generalize log2 to all Integral types with base >= 4.15 (GHC >= 9.0).

0.5.3 [2021.02.17]

  • The build-type has been changed from Custom to Simple. To achieve this, the doctests test suite has been removed in favor of using cabal-docspec to run the doctests.

0.5.2 [2019.05.02]

  • Support building with base-4.13 (GHC 8.8).
  • Add a MonadFail instance for Coding.


  • Fix off-by-one error in putUnaligned
  • Revamp Setup.hs to use cabal-doctest. This makes it build with Cabal-1.25, and makes the doctests work with cabal new-build and sandboxes.


  • ghc 8 support
  • Fixed doctests


  • Embrace FiniteBits from GHC 7.8.3 now that a platform has shipped with it.


  • Fixed dependencies on old busted versions


  • Bug fix for getBit


  • Fixed dependency bounds


  • Support for bytes 0.8


  • Claim to be Trustworthy


  • Crippled to work with bytes 0.7, so we can work with binary >= 0.6.


  • Repository initialized