bytable 0.0.0.3 → 0.0.0.4
raw patch · 2 files changed
+10/−5 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- bytable.cabal +2/−2
- src/Codec/Bytable/BigEndian.hs +8/−3
bytable.cabal view
@@ -2,7 +2,7 @@ build-type: Simple name: bytable-version: 0.0.0.3+version: 0.0.0.4 stability: Experimental author: Yoshikuni Jujo <PAF01143@nifty.ne.jp> maintainer: Yoshikuni Jujo <PAF01143@nifty.ne.jp>@@ -28,7 +28,7 @@ source-repository this type: git location: git://github.com/YoshikuniJujo/forest- tag: bytable-0.0.0.3+ tag: bytable-0.0.0.4 library hs-source-dirs: src
src/Codec/Bytable/BigEndian.hs view
@@ -12,7 +12,7 @@ | BS.length bs <= 4 = Right $ byteStringToNum bs | otherwise = Left "Codec.Bytable.BigEndian: Bytable Int: too large"- toByteString = integralToByteString+ toByteString = integralToByteStringN 4 instance Bytable Integer where fromByteString bs = Right $ byteStringToNum bs@@ -23,14 +23,14 @@ | BS.length bs <= 2 = Right $ byteStringToNum bs | otherwise = Left "Codec.Bytable.BigEndian: Bytable Word16: too large"- toByteString = integralToByteString+ toByteString = integralToByteStringN 2 instance Bytable Word32 where fromByteString bs | BS.length bs <= 4 = Right $ byteStringToNum bs | otherwise = Left "Codec.Bytable.BigEndian: Bytable Word32: too large"- toByteString = integralToByteString+ toByteString = integralToByteStringN 4 byteStringToNum :: (Num n, Bits n) => BS.ByteString -> n byteStringToNum = wordsToNum . reverse . BS.unpack@@ -41,6 +41,11 @@ integralToByteString :: (Integral n, Bits n) => n -> BS.ByteString integralToByteString = BS.pack . reverse . integralToWords++integralToByteStringN :: (Integral n, Bits n) => Int -> n -> BS.ByteString+integralToByteStringN n = BS.pack .+ (\ws -> replicate (n - length ws) 0 ++ ws) .+ reverse . integralToWords integralToWords :: (Integral n, Bits n) => n -> [Word8] integralToWords 0 = []