Copyright | © 2020 Alex Washburn |
---|---|
License | BSD-3-Clause |
Maintainer | github@recursion.ninja |
Stability | Stable |
Safe Haskell | Safe |
Language | GHC2021 |
A bit vector similar to Data.BitVector
from the
bv, however the endianness is
reversed. This module defines little-endian pseudo–size-polymorphic
bit vectors.
Little-endian bit vectors are isomorphic to a [Bool]
with the least
significant bit at the head of the list and the most significant bit at the
end of the list. Consequently, the endianness of a bit vector affects the semantics
of many type-classes that have a linear ordering.
For an implementation of bit vectors which are isomorphic to a [Bool]
with the most
significant bit at the head of the list and the least significant bit at the
end of the list, use the
bv package.
This module does not define numeric instances for BitVector
. This is
intentional! To interact with a bit vector as an Integral
value,
convert the BitVector
using either toSignedNumber
or toUnsignedNumber
.
This module defines rank
and select
operations for BitVector
as a
succinct data structure.
These operations are not o(1) so BitVector
is not a true succinct data
structure. However, it could potentially be extend to support this in the
future.
Synopsis
- data BitVector
- fromBits :: Foldable f => f Bool -> BitVector
- toBits :: BitVector -> [Bool]
- fromNumber :: Integral v => Word -> v -> BitVector
- toSignedNumber :: Num a => BitVector -> a
- toUnsignedNumber :: Num a => BitVector -> a
- dimension :: BitVector -> Word
- isZeroVector :: BitVector -> Bool
- subRange :: (Word, Word) -> BitVector -> BitVector
- rank :: BitVector -> Word -> Word
- select :: BitVector -> Word -> Maybe Word
Documentation
Instances
Bit-stream conversion
Numeric conversion
fromNumber :: Integral v => Word -> v -> BitVector #
toSignedNumber :: Num a => BitVector -> a #
toUnsignedNumber :: Num a => BitVector -> a #
Queries
isZeroVector :: BitVector -> Bool #