-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Encode binary protocols with some odd bit numbers into a bytestring -- -- Encode binary protocols with some odd bit numbers into a bytestring. @package bit-protocol @version 0.2.1.0 module Data.BitProtocol data BitsVal a BitsVal :: Natural -> a -> BitsVal a [bvBitsNum] :: BitsVal a -> Natural [bvVal] :: BitsVal a -> a -- | 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. encodeBS8 :: (Bits a, Integral a, Show a) => [BitsVal a] -> ByteString -- | 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. parseBS8 :: (Bits a, Integral a, Show a) => [Natural] -> ByteString -> ([BitsVal a], BitsVal a, ByteString) -- | Convert a number into a list of bools describing every bit. numberToBits :: (Integral a, Bits a) => BitsVal a -> [Bool] -- | Convert left 8 bits to a list of Word8, while giving a leftover -- value). Assumes that the BitsVal argument's length is more than -- 8. 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 -- | Read a single BitsVal from a BitsVal which wasn't -- consumed (part of a byte) and some ByteString big enough to -- cover that value readBitValue :: (Bits a, Integral a, Show a) => Natural -> BitsVal a -> ByteString -> (BitsVal a, BitsVal a) byteStringToBitsVal :: Integral a => ByteString -> BitsVal a instance GHC.Generics.Generic (Data.BitProtocol.BitsVal a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.BitProtocol.BitsVal a) instance GHC.Show.Show a => GHC.Show.Show (Data.BitProtocol.BitsVal a) instance Test.QuickCheck.Arbitrary.Arbitrary a => Test.QuickCheck.Arbitrary.Arbitrary (Data.BitProtocol.BitsVal a) instance GHC.Num.Num a => GHC.Base.Semigroup (Data.BitProtocol.BitsVal a) instance GHC.Real.Integral a => GHC.Base.Monoid (Data.BitProtocol.BitsVal a)