Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type BitBuffer64MaxLength = 64
- bitBuffer64MaxLength :: Int
- bitBuffer64MaxLengthBytes :: Word64
- data BitBuffer64
- bitBuffer64Content :: BitBuffer64 -> Word64
- bitBuffer64Length :: BitBuffer64 -> Int
- isBitBuffer64Empty :: BitBuffer64 -> Bool
- bitBuffer64SpaceLeft :: BitBuffer64 -> Int
- bitBuffer64 :: Int -> Word64 -> BitBuffer64
- emptyBitBuffer64 :: BitBuffer64
- bitBuffer64ProxyLength :: KnownChunkSize n => Proxy n -> Word64 -> BitBuffer64
- bufferBits :: BitBuffer64 -> BitBuffer64 -> (BitBuffer64, BitBuffer64)
- type family KnownChunkSize (s :: Nat) :: Constraint where ...
Documentation
type BitBuffer64MaxLength = 64 Source #
The maximum number of bits a BitBuffer
can hold.
bitBuffer64MaxLength :: Int Source #
The maximum number of bits a BitBuffer
can hold.
bitBuffer64MaxLengthBytes :: Word64 Source #
The maximum number of bytes a BitBuffer
can hold.
data BitBuffer64 Source #
A buffer for 64 bits, such that the bits are written MSB to LSB.
type TwoFields = "f0" @: Field m .+. "f1" @: Field n
Writes:
MSB LSB
Bit: |k .. k-(m+1)|k-m .. k-(m+n+1)|k-(m+n) .. 0|
Value: |------f0------|--------f1--------|XXXXXXXXXXXXXX|
Where k
is the current bit offset.
The input values are expected to be in the order of the fields, i.e.:
toFunction $ bitBuffer64Builder (Proxy :: Proxy TwoFields) 1 2
Will result in:
MSB LSB
Bit: |k .. k-(m+1)|k-m .. k-(m+n+1)| k-(m+n) .. 0|
Value: |0 .. 1|0 .. 10| X .. X|
The string of bits with a given length (but always <=
.
The number of bits must be smaller that bitBuffer64MaxLength
bitBuffer64MaxLength
.
Instances
HasFunctionBuilder BitBuilder BitBuffer64 Source # | |
Defined in Data.Type.BitRecords.Builder.LazyByteStringBuilder type ToFunction BitBuilder BitBuffer64 r :: Type # | |
HasFunctionBuilder BitBuilder BitBuffer64 Source # | |
Defined in Data.Type.BitRecords.Writer.ByteStringBuilder type ToFunction BitBuilder BitBuffer64 r :: Type # | |
type ToFunction BitBuilder BitBuffer64 r Source # | |
type ToFunction BitBuilder BitBuffer64 r Source # | |
bitBuffer64Length :: BitBuffer64 -> Int Source #
isBitBuffer64Empty :: BitBuffer64 -> Bool Source #
bitBuffer64 :: Int -> Word64 -> BitBuffer64 Source #
Create a BitBuffer64
containing len
bits from LSB to MSB, properly
masked, such that only len
least significant bits are kept..
emptyBitBuffer64 :: BitBuffer64 Source #
Create an empty BitBuffer64
.
bitBuffer64ProxyLength :: KnownChunkSize n => Proxy n -> Word64 -> BitBuffer64 Source #
Create a BitBuffer64
with a length given by a Proxy
to a type level
Nat
.
:: BitBuffer64 | The value to write (in the lower |
-> BitBuffer64 | The input to write to (starting from length) |
-> (BitBuffer64, BitBuffer64) | The remaining bits that did not fit in the buffer and the output buffer. |
Copy bits starting at a specific offset from one a
the the other.
Set bits starting from the most significant bit to the least.
For example writeBits m 1 <> writeBits n 2
would result in:
MSB LSB Bit: |k .. k-(m+1)|k-m .. k-(m+n+1)| k-(m+n) .. 0| Value: |0 .. 1|0 .. 10| ... | -> -> -> (direction of writing)
type family KnownChunkSize (s :: Nat) :: Constraint where ... Source #
KnownChunkSize size = (KnownNat size, size <= BitBuffer64MaxLength) |