bitvec: Space-efficient bit vectors
A newtype over Bool with a better Vector instance: 8x less memory, up to 3500x faster.
The vector
package represents unboxed arrays of Bools
spending 1 byte (8 bits) per boolean.
This library provides a newtype wrapper Bit and a custom instance
of an unboxed Vector, which packs bits densely,
achieving an 8x smaller memory footprint.
The performance stays mostly the same;
the most significant degradation happens for random writes
(up to 10% slower).
On the other hand, for certain bulk bit operations
Vector Bit is up to 3500x faster than Vector Bool.
Thread safety
Data.Bit is faster, but writes and flips are not thread-safe. This is because naive updates are not atomic: they read the whole word from memory, then modify a bit, then write the whole word back. Concurrently modifying non-intersecting slices of the same underlying array may also lead to unexpected results, since they can share a word in memory.
Data.Bit.ThreadSafe is slower (usually 10-20%), but writes and flips are thread-safe. Additionally, concurrently modifying non-intersecting slices of the same underlying array works as expected. However, operations that affect multiple elements are not guaranteed to be atomic.
Similar packages
array is memory-efficient for
Bool, but lacks a handyVectorinterface and is not thread-safe.
[Skip to Readme]
Flags
Manual Flags
| Name | Description | Default |
|---|---|---|
| simd | Use a C SIMD implementation for the ultimate performance of | Enabled |
Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info
Downloads
- bitvec-1.1.6.0.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
| Versions [RSS] | 0.1, 0.1.0.1, 0.1.0.2, 0.1.1.0, 0.2.0.0, 0.2.0.1, 1.0.0.0, 1.0.0.1, 1.0.1.0, 1.0.1.1, 1.0.1.2, 1.0.2.0, 1.0.3.0, 1.1.0.0, 1.1.1.0, 1.1.2.0, 1.1.3.0, 1.1.4.0, 1.1.5.0, 1.1.6.0 (info) |
|---|---|
| Change log | changelog.md |
| Dependencies | base (>=4.15 && <5), bytestring (>=0.10 && <0.13), deepseq (<1.6), ghc-bignum (<1.5), primitive (>=0.5 && <0.10), vector (>=0.13 && <0.14) [details] |
| Tested with | ghc ==9.0.2, ghc ==9.2.8, ghc ==9.4.8, ghc ==9.6.7, ghc ==9.8.4, ghc ==9.10.3, ghc ==9.12.2, ghc ==9.14.1 |
| License | BSD-3-Clause |
| Copyright | 2019-2022 Andrew Lelechenko, 2012-2016 James Cook |
| Author | Andrew Lelechenko <andrew.lelechenko@gmail.com>, James Cook <mokus@deepbondi.net> |
| Maintainer | Andrew Lelechenko <andrew.lelechenko@gmail.com> |
| Uploaded | by Bodigrim at 2026-02-18T00:32:25Z |
| Category | Data, Bit Vectors |
| Home page | https://github.com/Bodigrim/bitvec |
| Source repo | head: git clone https://github.com/Bodigrim/bitvec.git |
| Distributions | Arch:1.1.5.0, Fedora:1.1.5.0, LTSHaskell:1.1.5.0, NixOS:1.1.5.0, Stackage:1.1.6.0, openSUSE:1.1.5.0 |
| Reverse Dependencies | 20 direct, 8585 indirect [details] |
| Downloads | 18177 total (78 in the last 30 days) |
| Rating | 2.25 (votes: 2) [estimated by Bayesian average] |
| Your Rating | |
| Status | Docs available [build log] Last success reported on 2026-02-18 [all 1 reports] |