Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data BitsVal a = BitsVal {}
- encodeBS8 :: (Bits a, Integral a, Show a) => [BitsVal a] -> ByteString
- parseBS8 :: (Bits a, Integral a, Show a) => [Natural] -> ByteString -> ([BitsVal a], BitsVal a, ByteString)
- parseBS8Prefixed :: (Bits a, Integral a, Show a) => [Natural] -> ByteString -> BitsVal a -> ([BitsVal a], BitsVal a, ByteString)
- numberToBits :: (Integral a, Bits a) => BitsVal a -> [Bool]
- bitsValBiggerToCharUnsafe :: (Bits a, Integral a, Show a) => BitsVal a -> ([Word8], BitsVal a)
- word8sToIntegral :: Integral a => [Word8] -> a
- numToWord8Array :: (Integral a, Bits a) => BitsVal a -> [Word8]
- roundTo8 :: (Integral a, Show a) => BitsVal a -> BitsVal a
- readBitValue :: (Bits a, Integral a, Show a) => Natural -> BitsVal a -> ByteString -> (BitsVal a, BitsVal a)
- byteStringToBitsVal :: Integral a => ByteString -> BitsVal a
Documentation
Instances
Eq a => Eq (BitsVal a) Source # | |
Show a => Show (BitsVal a) Source # | |
Generic (BitsVal a) Source # | |
Num a => Semigroup (BitsVal a) Source # | |
Integral a => Monoid (BitsVal a) Source # | WARNING! Can overflow, so only concat on a small number of items |
Arbitrary a => Arbitrary (BitsVal a) Source # | |
type Rep (BitsVal a) Source # | |
Defined in Data.BitProtocol type Rep (BitsVal a) = D1 (MetaData "BitsVal" "Data.BitProtocol" "bit-protocol-0.2.3.0-2DEq4wlTM6ZD0TMOS1pZ9U" False) (C1 (MetaCons "BitsVal" PrefixI True) (S1 (MetaSel (Just "bvBitsNum") NoSourceUnpackedness NoSourceStrictness DecidedStrict) (Rec0 Natural) :*: S1 (MetaSel (Just "bvVal") NoSourceUnpackedness NoSourceStrictness DecidedStrict) (Rec0 a))) |
encodeBS8 :: (Bits a, Integral a, Show a) => [BitsVal a] -> ByteString Source #
Converts a list of chars into a bytestring via construction of 8-bit chars. Pads with zeroes on the right if a sum is not divisible by 8.
parseBS8 :: (Bits a, Integral a, Show a) => [Natural] -> ByteString -> ([BitsVal a], BitsVal a, ByteString) Source #
Parse a ByteString
by a given spec. Return the values consumed,
a leftover BitsVal (will be 'BitsVal 0 0' for fully-consumed byte,
something else for a half-consumed one) and a leftover ByteString
tail.
parseBS8Prefixed :: (Bits a, Integral a, Show a) => [Natural] -> ByteString -> BitsVal a -> ([BitsVal a], BitsVal a, ByteString) Source #
Parse a ByteString
which also has some non-consumed prefix with
a number of bits under 8 usually.
helpers / nice things to have
numberToBits :: (Integral a, Bits a) => BitsVal a -> [Bool] Source #
Convert a number into a list of bools describing every bit.
internal
bitsValBiggerToCharUnsafe :: (Bits a, Integral a, Show a) => BitsVal a -> ([Word8], BitsVal a) Source #
word8sToIntegral :: Integral a => [Word8] -> a Source #
readBitValue :: (Bits a, Integral a, Show a) => Natural -> BitsVal a -> ByteString -> (BitsVal a, BitsVal a) Source #
Read a single BitsVal
from a BitsVal
which wasn't consumed
(part of a byte) and some ByteString
big enough to cover that
value
byteStringToBitsVal :: Integral a => ByteString -> BitsVal a Source #