The current vector
package represents unboxed arrays of Bool
allocating one byte per boolean, which might be considered wasteful.
This library provides a newtype wrapper Data.Bit.Bit and a custom instance
of unboxed Data.Vector.Unboxed.Vector, which packs booleans densely.
It is a time-memory tradeoff: 8x less memory footprint
at the price of moderate performance penalty
(mostly, for random writes).
Thread safety
Data.Bit is faster, but thread-unsafe. This is because
naive updates are not atomic operations: read the whole word from memory,
modify a bit, write the whole word back.
Data.Bit.ThreadSafe is slower (up to 2x), but thread-safe.
Similar packages
bv
and bv-little
offer only immutable size-polymorphic bit vectors.
bitvec provides an interface to mutable vectors as well.
array
is memory-efficient for Bool, but lacks
a handy Vector interface and is not thread-safe.