mempack 0.1.1.0 → 0.1.2.0
raw patch · 5 files changed
+30/−11 lines, 5 filesdep ~random
Dependency ranges changed: random
Files
- CHANGELOG.md +4/−0
- mempack.cabal +3/−4
- src/Data/MemPack.hs +9/−7
- tests/Test/Common.hs +11/−0
- tests/Test/MemPackSpec.hs +3/−0
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Changelog for `mempack` +## 0.1.2.0++* Fix 32-bit support+ ## 0.1.1.0 * Add helpers `packByteStringM`, `unpackByteStringM` and `unpackByteArrayLen`
mempack.cabal view
@@ -1,5 +1,5 @@ name: mempack-version: 0.1.1.0+version: 0.1.2.0 synopsis: Short description description: Please see the README on GitHub at <https://github.com/lehins/mempack#readme> homepage: https://github.com/lehins/mempack@@ -19,7 +19,7 @@ , GHC == 9.0.2 , GHC == 9.2.8 , GHC == 9.4.8- , GHC == 9.6.6+ , GHC == 9.6.7 , GHC == 9.8.4 , GHC == 9.10.1 , GHC == 9.12.1@@ -92,8 +92,7 @@ , mempack , serialise , store- -- This upper bound is necessary to unscrew store building- , vector <0.13.2+ , vector default-language: Haskell2010 source-repository head
src/Data/MemPack.hs view
@@ -322,9 +322,11 @@ buf (\ba# -> C# (indexWord8ArrayAsWideChar# ba# i#)) (\addr# -> C# (indexWideCharOffAddr# (addr# `plusAddr#` i#) 0#))- when (ord c > 0x10FFFF) $+ ordc :: Word32+ ordc = fromIntegral (ord c)+ when (ordc > 0x10FFFF) $ F.fail $- "Out of bounds Char was detected: '\\x" ++ showHex (fromEnum c) "'"+ "Out of bounds Char was detected: '\\x" ++ showHex ordc "'" pure c {-# INLINE unpackM #-} @@ -1286,16 +1288,16 @@ packedByteCount = packedVarLenByteCount {-# INLINE packedByteCount #-} #if WORD_SIZE_IN_BITS == 32- packM mba v@(VarLen x) = p7 (p7 (p7 (p7 (p7 (errorTooManyBits "Word"))))) (numBits - 7)+ packM v@(VarLen x) = p7 (p7 (p7 (p7 (p7 (errorTooManyBits "Word"))))) (numBits - 7) where- p7 = packIntoCont7 mba x+ p7 = packIntoCont7 x {-# INLINE p7 #-} numBits = packedVarLenByteCount v * 7 {-# INLINE packM #-}- unpackM buf = do- let d7 = unpack7BitVarLen buf+ unpackM = do+ let d7 = unpack7BitVarLen {-# INLINE d7 #-}- VarLen <$> d7 (d7 (d7 (d7 (unpack7BitVarLenLast buf 0b_1111_0000)))) 0 0+ VarLen <$> d7 (d7 (d7 (d7 (unpack7BitVarLenLast 0b_1111_0000)))) 0 0 {-# INLINE unpackM #-} #elif WORD_SIZE_IN_BITS == 64 packM v@(VarLen x) =
tests/Test/Common.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# OPTIONS_GHC -Wno-orphans #-} @@ -25,9 +26,15 @@ {-# INLINE uniformWord32 #-} uniformWord64 QC = MkGen (\r _n -> runStateGen_ r uniformWord64) {-# INLINE uniformWord64 #-}+#if MIN_VERSION_random(1,3,0)+ uniformByteArrayM pinned k QC =+ MkGen (\r _n -> runStateGen_ r (uniformByteArrayM pinned k))+ {-# INLINE uniformByteArrayM #-}+#else uniformShortByteString k QC = MkGen (\r _n -> runStateGen_ r (uniformShortByteString k)) {-# INLINE uniformShortByteString #-}+#endif instance Arbitrary ByteArray where arbitrary = qcByteArray . getNonNegative =<< arbitrary@@ -51,4 +58,8 @@ qcByteString n = uniformByteStringM (fromIntegral n) QC qcShortByteString :: Int -> Gen SBS.ShortByteString+#if MIN_VERSION_random(1,3,0)+qcShortByteString n = uniformShortByteStringM (fromIntegral n) QC+#else qcShortByteString n = uniformShortByteString (fromIntegral n) QC+#endif
tests/Test/MemPackSpec.hs view
@@ -59,6 +59,9 @@ uniformM = uniformEnumM instance UniformRange Length where uniformRM = uniformEnumRM+#if MIN_VERSION_random(1,3,0)+ isInRange = isInRangeEnum+#endif instance Arbitrary Length where -- Fun fact: `abs minBound == minBound` for Int, so instead of abs we clear top most