packages feed

bit-protocol 0.2.1.0 → 0.2.2.0

raw patch · 2 files changed

+16/−6 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.BitProtocol: parseBS8Prefixed :: (Bits a, Integral a, Show a) => [Natural] -> ByteString -> BitsVal a -> ([BitsVal a], BitsVal a, ByteString)

Files

bit-protocol.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 51fcbce5462295f23a2a6b98b1433cfbb27309fa7ed82d1e05c71d43b12a0b52+-- hash: da0f8e1767f716ba8e01975185dad2a9cffe3e268e0f70bbb628b436b06de3a9  name:           bit-protocol-version:        0.2.1.0+version:        0.2.2.0 synopsis:       Encode binary protocols with some odd bit numbers into a bytestring description:    Encode binary protocols with some odd bit numbers into a bytestring. category:       Data, Parsing, Bits, Bytes, Protocols
src/Data/BitProtocol.hs view
@@ -9,6 +9,7 @@   ( BitsVal(..)   , encodeBS8   , parseBS8+  , parseBS8Prefixed   -- * helpers / nice things to have   , numberToBits   -- * internal@@ -148,8 +149,18 @@   => [Natural]   -> ByteString   -> ([BitsVal a], BitsVal a, ByteString)-parseBS8 bitLengths input =-  let (bitVals, bvInp, rest) = go bitLengths (BitsVal 0 0) input DL.empty+parseBS8 bitLengths input = parseBS8Prefixed bitLengths input (BitsVal 0 0)++-- | Parse a 'ByteString' which also has some non-consumed prefix with+-- a number of bits under 8 usually.+parseBS8Prefixed ::+     (Bits a, Integral a, Show a)+  => [Natural]+  -> ByteString+  -> BitsVal a+  -> ([BitsVal a], BitsVal a, ByteString)+parseBS8Prefixed bitLengths input prefix =+  let (bitVals, bvInp, rest) = go bitLengths prefix input DL.empty    in (bitVals, bvInp, rest)   where     go [] bvInp inp acc = (DL.toList acc, bvInp, inp)@@ -165,8 +176,7 @@  -- | Convert a number into a list of bools describing every bit. numberToBits :: (Integral a, Bits a) => BitsVal a -> [Bool]-numberToBits (BitsVal len val) =-  map getBit [1..len']+numberToBits (BitsVal len val) = map getBit [1 .. len']   where     len' = fromIntegral len     getBit i = testBit val (len' - i)