dahdit 0.5.0 → 0.5.1
raw patch · 8 files changed
+177/−36 lines, 8 filesdep ~freedep ~mtldep ~transformersPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: free, mtl, transformers
API changes (from Hackage documentation)
Files
- dahdit.cabal +7/−7
- src/Dahdit/Funs.hs +24/−3
- src/Dahdit/Iface.hs +31/−6
- src/Dahdit/LiftedPrim.hs +19/−2
- src/Dahdit/LiftedPrimArray.hs +4/−2
- src/Dahdit/Mem.hs +11/−1
- src/Dahdit/Run.hs +29/−4
- test/Main.hs +52/−11
dahdit.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: dahdit-version: 0.5.0+version: 0.5.1 synopsis: Binary parsing and serialization with integrated size description: Please see the README on GitHub at <https://github.com/ejconlon/dahdit#readme> category: Data@@ -80,12 +80,12 @@ , containers ==0.6.* , data-default ==0.7.* , data-sword ==0.2.*- , free ==5.1.*+ , free >=5.1 && <5.3 , ghc-typelits-knownnat ==0.7.*- , mtl ==2.2.*+ , mtl >=2.2 && <2.4 , primitive >=0.7 && <0.9 , text >=1.2 && <2.1- , transformers ==0.5.*+ , transformers >=0.5 && <0.7 , vector >=0.12 && <0.14 default-language: Haskell2010 @@ -131,13 +131,13 @@ , data-default ==0.7.* , data-sword ==0.2.* , falsify ==0.2.*- , free ==5.1.*+ , free >=5.1 && <5.3 , ghc-typelits-knownnat ==0.7.*- , mtl ==2.2.*+ , mtl >=2.2 && <2.4 , primitive >=0.7 && <0.9 , tasty ==1.4.* , tasty-hunit ==0.10.* , text >=1.2 && <2.1- , transformers ==0.5.*+ , transformers >=0.5 && <0.7 , vector >=0.12 && <0.14 default-language: Haskell2010
src/Dahdit/Funs.hs view
@@ -282,7 +282,14 @@ let left = rem bc ebc if left == 0 then getStaticSeq (coerce (div bc ebc)) g- else fail ("Leftover bytes for remaining static seq (have " ++ show (unByteCount left) ++ ", need " ++ show (unByteCount ebc) ++ ")")+ else+ fail+ ( "Leftover bytes for remaining static seq (have "+ ++ show (unByteCount left)+ ++ ", need "+ ++ show (unByteCount ebc)+ ++ ")"+ ) getRemainingStaticArray :: (LiftedPrim a) => Proxy a -> Get (LiftedPrimArray a) getRemainingStaticArray prox = do@@ -291,7 +298,14 @@ let left = rem bc ebc if left == 0 then getStaticArray (coerce (div bc ebc))- else fail ("Leftover bytes for remaining static array (have " ++ show (unByteCount left) ++ ", need " ++ show (unByteCount ebc) ++ ")")+ else+ fail+ ( "Leftover bytes for remaining static array (have "+ ++ show (unByteCount left)+ ++ ", need "+ ++ show (unByteCount ebc)+ ++ ")"+ ) getRemainingByteArray :: Get ByteArray getRemainingByteArray = getRemainingSize >>= getByteArray@@ -305,7 +319,14 @@ then do let ec = coerce (div bc ebc) getLiftedPrimArray prox ec- else fail ("Leftover bytes for remaining lifted prim array (have " ++ show (unByteCount left) ++ ", need " ++ show (unByteCount ebc) ++ ")")+ else+ fail+ ( "Leftover bytes for remaining lifted prim array (have "+ ++ show (unByteCount left)+ ++ ", need "+ ++ show (unByteCount ebc)+ ++ ")"+ ) getExpect :: (Eq a, Show a) => String -> Get a -> a -> Get () getExpect typ getter expec = do
src/Dahdit/Iface.hs view
@@ -23,8 +23,29 @@ import Dahdit.Binary (Binary (..)) import Dahdit.Free (Get, Put) import Dahdit.Funs (getRemainingSize)-import Dahdit.Mem (MemPtr (..), MutableMem (..), emptyMemPtr, mutViewVecMem, viewBSMem, viewSBSMem, viewVecMem, withBAMem, withBSMem, withSBSMem, withVecMem)-import Dahdit.Run (GetError, GetIncCb, GetIncChunk (..), newGetIncEnv, runCount, runGetIncInternal, runGetInternal, runPutInternal)+import Dahdit.Mem+ ( MemPtr (..)+ , MutableMem (..)+ , emptyMemPtr+ , mutViewVecMem+ , viewBSMem+ , viewSBSMem+ , viewVecMem+ , withBAMem+ , withBSMem+ , withSBSMem+ , withVecMem+ )+import Dahdit.Run+ ( GetError+ , GetIncCb+ , GetIncChunk (..)+ , newGetIncEnv+ , runCount+ , runGetIncInternal+ , runGetInternal+ , runPutInternal+ ) import Dahdit.Sizes (ByteCount (..)) import Data.ByteString (ByteString) import qualified Data.ByteString as BS@@ -142,7 +163,8 @@ decode = getTarget get -- | Decode a value incrementally from sources yielded by a callback.-decodeInc :: (Binary a, BinaryGetTarget z m) => Maybe ByteCount -> GetIncCb z m -> m (Either GetError a, ByteCount, ByteCount)+decodeInc+ :: (Binary a, BinaryGetTarget z m) => Maybe ByteCount -> GetIncCb z m -> m (Either GetError a, ByteCount, ByteCount) decodeInc mayCap = getTargetInc mayCap get -- | 'decode' but expect the end of input.@@ -198,17 +220,20 @@ runGetIncText :: Maybe ByteCount -> Get a -> GetIncCb Text IO -> IO (Either GetError a, ByteCount, ByteCount) runGetIncText mayCap g cb = runGetIncBS mayCap g (fmap (fmap TE.encodeUtf8) . cb) -runGetIncBA :: (PrimMonad m) => Maybe ByteCount -> Get a -> GetIncCb ByteArray m -> m (Either GetError a, ByteCount, ByteCount)+runGetIncBA+ :: (PrimMonad m) => Maybe ByteCount -> Get a -> GetIncCb ByteArray m -> m (Either GetError a, ByteCount, ByteCount) runGetIncBA mayCap act cb = do env <- newGetIncEnv mayCap (GetIncChunk 0 0 emptyByteArray) let view s = GetIncChunk 0 (coerce (sizeofByteArray s)) s let cb' = fmap (fmap view) . cb runGetIncInternal act env cb' -runGetIncSBS :: (PrimMonad m) => Maybe ByteCount -> Get a -> GetIncCb ShortByteString m -> m (Either GetError a, ByteCount, ByteCount)+runGetIncSBS+ :: (PrimMonad m) => Maybe ByteCount -> Get a -> GetIncCb ShortByteString m -> m (Either GetError a, ByteCount, ByteCount) runGetIncSBS mayCap act cb = runGetIncBA mayCap act (fmap (fmap viewSBSMem) . cb) -runGetIncMemPtr :: Maybe ByteCount -> Get a -> GetIncCb (MemPtr RealWorld) IO -> IO (Either GetError a, ByteCount, ByteCount)+runGetIncMemPtr+ :: Maybe ByteCount -> Get a -> GetIncCb (MemPtr RealWorld) IO -> IO (Either GetError a, ByteCount, ByteCount) runGetIncMemPtr mayCap act cb = do mem <- emptyMemPtr env <- newGetIncEnv mayCap (GetIncChunk 0 0 mem)
src/Dahdit/LiftedPrim.hs view
@@ -11,7 +11,23 @@ where import Control.Monad.Primitive (PrimMonad (..))-import Dahdit.Internal (EndianPair (..), ViaEndianPair (..), ViaFromIntegral (..), mkDoubleLE, mkFloatLE, mkWord16LE, mkWord24LE, mkWord32LE, mkWord64LE, unMkDoubleLE, unMkFloatLE, unMkWord16LE, unMkWord24LE, unMkWord32LE, unMkWord64LE)+import Dahdit.Internal+ ( EndianPair (..)+ , ViaEndianPair (..)+ , ViaFromIntegral (..)+ , mkDoubleLE+ , mkFloatLE+ , mkWord16LE+ , mkWord24LE+ , mkWord32LE+ , mkWord64LE+ , unMkDoubleLE+ , unMkFloatLE+ , unMkWord16LE+ , unMkWord24LE+ , unMkWord32LE+ , unMkWord64LE+ ) import Dahdit.Nums ( DoubleBE , DoubleLE (..)@@ -322,7 +338,8 @@ deriving via (ViaEndianPair 8 DoubleLE DoubleBE) instance LiftedPrim DoubleBE -- | Fill a byte array with the given value-setByteArrayLifted :: (PrimMonad m, LiftedPrim a) => MutableByteArray (PrimState m) -> ByteCount -> ByteCount -> a -> m ()+setByteArrayLifted+ :: (PrimMonad m, LiftedPrim a) => MutableByteArray (PrimState m) -> ByteCount -> ByteCount -> a -> m () setByteArrayLifted arr off len val = do let elemSize = staticByteSize (proxyFor val) elemLen = div (coerce len) elemSize
src/Dahdit/LiftedPrimArray.hs view
@@ -64,13 +64,15 @@ writeLiftedPrimArray :: (LiftedPrim a, PrimMonad m) => MutableLiftedPrimArray (PrimState m) a -> ElemCount -> a -> m () writeLiftedPrimArray (MutableLiftedPrimArray arr) = writeArrayLiftedInElems arr -freezeLiftedPrimArray :: (PrimMonad m) => MutableLiftedPrimArray (PrimState m) a -> ElemCount -> ElemCount -> m (LiftedPrimArray a)+freezeLiftedPrimArray+ :: (PrimMonad m) => MutableLiftedPrimArray (PrimState m) a -> ElemCount -> ElemCount -> m (LiftedPrimArray a) freezeLiftedPrimArray (MutableLiftedPrimArray arr) off len = fmap LiftedPrimArray (freezeByteArray arr (coerce off) (coerce len)) unsafeFreezeLiftedPrimArray :: (PrimMonad m) => MutableLiftedPrimArray (PrimState m) a -> m (LiftedPrimArray a) unsafeFreezeLiftedPrimArray (MutableLiftedPrimArray arr) = fmap LiftedPrimArray (unsafeFreezeByteArray arr) -thawLiftedPrimArray :: (PrimMonad m) => LiftedPrimArray a -> ElemCount -> ElemCount -> m (MutableLiftedPrimArray (PrimState m) a)+thawLiftedPrimArray+ :: (PrimMonad m) => LiftedPrimArray a -> ElemCount -> ElemCount -> m (MutableLiftedPrimArray (PrimState m) a) thawLiftedPrimArray (LiftedPrimArray arr) off len = fmap MutableLiftedPrimArray (thawByteArray arr (coerce off) (coerce len)) unsafeThawLiftedPrimArray :: (PrimMonad m) => LiftedPrimArray a -> m (MutableLiftedPrimArray (PrimState m) a)
src/Dahdit/Mem.hs view
@@ -26,7 +26,17 @@ import Data.ByteString.Short.Internal (ShortByteString (..)) import Data.Coerce (coerce) import Data.Foldable (for_)-import Data.Primitive.ByteArray (ByteArray (..), MutableByteArray, cloneByteArray, copyByteArray, copyByteArrayToPtr, freezeByteArray, newByteArray, unsafeFreezeByteArray, unsafeThawByteArray)+import Data.Primitive.ByteArray+ ( ByteArray (..)+ , MutableByteArray+ , cloneByteArray+ , copyByteArray+ , copyByteArrayToPtr+ , freezeByteArray+ , newByteArray+ , unsafeFreezeByteArray+ , unsafeThawByteArray+ ) import Data.Primitive.Ptr (copyPtrToMutableByteArray) import Data.Vector.Storable (Vector) import qualified Data.Vector.Storable as VS
src/Dahdit/Run.hs view
@@ -114,12 +114,32 @@ prettyGetError :: GetError -> Text prettyGetError = \case- GetErrorLocalCap nm ac bc -> "End of chunk parsing " <> nm <> " (have " <> T.pack (show (unByteCount ac)) <> " bytes, need " <> T.pack (show (unByteCount bc)) <> ")"+ GetErrorLocalCap nm ac bc ->+ "End of chunk parsing "+ <> nm+ <> " (have "+ <> T.pack (show (unByteCount ac))+ <> " bytes, need "+ <> T.pack (show (unByteCount bc))+ <> ")" GetErrorScopedMismatch sm ac bc -> let ty = case sm of ScopeModeExact -> "exact"; ScopeModeWithin -> "within"- in "Did not parse " <> ty <> " scoped input (read " <> T.pack (show (unByteCount ac)) <> " bytes, expected " <> T.pack (show (unByteCount bc)) <> ")"+ in "Did not parse "+ <> ty+ <> " scoped input (read "+ <> T.pack (show (unByteCount ac))+ <> " bytes, expected "+ <> T.pack (show (unByteCount bc))+ <> ")" GetErrorFail msg -> "User error: " <> msg- GetErrorGlobalCap nm ac bc -> "Hit limit parsing " <> nm <> " (allowed " <> T.pack (show (unByteCount ac)) <> " bytes, need " <> T.pack (show (unByteCount bc)) <> ")"+ GetErrorGlobalCap nm ac bc ->+ "Hit limit parsing "+ <> nm+ <> " (allowed "+ <> T.pack (show (unByteCount ac))+ <> " bytes, need "+ <> T.pack (show (unByteCount bc))+ <> ")" GetErrorRemaining ac -> "Cannot read remaining length in stream context (read " <> T.pack (show (unByteCount ac)) <> ")" -- | Get from a single buffer@@ -345,7 +365,12 @@ _ :|> cap -> k (cap - gloAbs) GetFFail msg -> throwError (GetErrorFail msg) -runGetIncInternal :: (MonadPrim s m, ReadMem r m) => Get a -> GetIncEnv s r -> GetIncCbChunk r m -> m (Either GetError a, ByteCount, ByteCount)+runGetIncInternal+ :: (MonadPrim s m, ReadMem r m)+ => Get a+ -> GetIncEnv s r+ -> GetIncCbChunk r m+ -> m (Either GetError a, ByteCount, ByteCount) runGetIncInternal getter env cb = do let m = interpGetInc getter res <- runGetIncM m env cb
test/Main.hs view
@@ -129,7 +129,14 @@ import Data.Coerce (coerce) import Data.IORef (modifyIORef', newIORef, readIORef, writeIORef) import Data.Int (Int16, Int32, Int64, Int8)-import Data.Primitive.ByteArray (ByteArray (..), MutableByteArray, byteArrayFromList, freezeByteArray, newByteArray, sizeofMutableByteArray)+import Data.Primitive.ByteArray+ ( ByteArray (..)+ , MutableByteArray+ , byteArrayFromList+ , freezeByteArray+ , newByteArray+ , sizeofMutableByteArray+ ) import Data.Proxy (asProxyTypeOf) import Data.Sequence (Seq (..)) import qualified Data.Sequence as Seq@@ -363,15 +370,27 @@ , GetCase "Int64BE" getInt64BE (Just (8, 0, 0x5DEC6EFD12345678)) [0x5D, 0xEC, 0x6E, 0xFD, 0x12, 0x34, 0x56, 0x78] , GetCase "FloatLE" getFloatLE (Just (4, 0, FloatLE (castWord32ToFloat 0x5DEC6EFD))) [0xFD, 0x6E, 0xEC, 0x5D] , GetCase "FloatBE" getFloatBE (Just (4, 0, FloatBE (castWord32ToFloat 0x5DEC6EFD))) [0x5D, 0xEC, 0x6E, 0xFD]- , GetCase "DoubleLE" getDoubleLE (Just (8, 0, DoubleLE (castWord64ToDouble 0x5DEC6EFD12345678))) [0x78, 0x56, 0x34, 0x12, 0xFD, 0x6E, 0xEC, 0x5D]- , GetCase "DoubleBE" getDoubleBE (Just (8, 0, DoubleBE (castWord64ToDouble 0x5DEC6EFD12345678))) [0x5D, 0xEC, 0x6E, 0xFD, 0x12, 0x34, 0x56, 0x78]+ , GetCase+ "DoubleLE"+ getDoubleLE+ (Just (8, 0, DoubleLE (castWord64ToDouble 0x5DEC6EFD12345678)))+ [0x78, 0x56, 0x34, 0x12, 0xFD, 0x6E, 0xEC, 0x5D]+ , GetCase+ "DoubleBE"+ getDoubleBE+ (Just (8, 0, DoubleBE (castWord64ToDouble 0x5DEC6EFD12345678)))+ [0x5D, 0xEC, 0x6E, 0xFD, 0x12, 0x34, 0x56, 0x78] , GetCase "ShortByteString" (getByteString 2) (Just (2, 1, BSS.pack [0xEC, 0x5D])) [0xEC, 0x5D, 0xBB] , GetCase "Text" (getText 2) (Just (2, 1, "hi")) [0x68, 0x69, 0xBB] , GetCase "Two Word8" ((,) <$> getWord8 <*> getWord8) (Just (2, 0, (0x5D, 0xBB))) [0x5D, 0xBB] , GetCase "Two Word16LE" ((,) <$> getWord16LE <*> getWord16LE) (Just (4, 0, (0x5DEC, 0x4020))) [0xEC, 0x5D, 0x20, 0x40] , GetCase "Seq" (getSeq 2 getWord16LE) (Just (4, 0, Seq.fromList [0x5DEC, 0x4020])) [0xEC, 0x5D, 0x20, 0x40] , GetCase "StaticSeq" (getStaticSeq 2 getWord16LE) (Just (4, 0, Seq.fromList [0x5DEC, 0x4020])) [0xEC, 0x5D, 0x20, 0x40]- , GetCase "StaticArray" (getStaticArray @Word16LE 2) (Just (4, 0, liftedPrimArrayFromList [0x5DEC, 0x4020])) [0xEC, 0x5D, 0x20, 0x40]+ , GetCase+ "StaticArray"+ (getStaticArray @Word16LE 2)+ (Just (4, 0, liftedPrimArrayFromList [0x5DEC, 0x4020]))+ [0xEC, 0x5D, 0x20, 0x40] , GetCase "DynFoo" (get @DynFoo) (Just (3, 0, DynFoo 0xBB 0x5DEC)) [0xBB, 0xEC, 0x5D] , GetCase "StaFoo" (get @StaFoo) (Just (3, 0, StaFoo 0xBB 0x5DEC)) [0xBB, 0xEC, 0x5D] , GetCase "getRemainingSize" getRemainingSize (Just (0, 3, 3)) [0xBB, 0xEC, 0x5D]@@ -387,8 +406,16 @@ , GetCase "getWithin gt" (getWithin 3 getWord16LE) (Just (2, 1, 0x5DEC)) [0xEC, 0x5D, 0xBB] , GetCase "BoolByte True" (get @BoolByte) (Just (1, 0, BoolByte True)) [0x01] , GetCase "BoolByte False" (get @BoolByte) (Just (1, 0, BoolByte False)) [0x00]- , GetCase "getByteArray" (getByteArray 3) (Just (3, 1, byteArrayFromList @Word8 [0xFD, 0x6E, 0xEC])) [0xFD, 0x6E, 0xEC, 0x5D]- , GetCase "getLiftedPrimArray" (getLiftedPrimArray (Proxy :: Proxy Word16LE) 3) (Just (6, 1, liftedPrimArrayFromList @Word16LE [0xFD, 0x6E, 0xEC])) [0xFD, 0x00, 0x6E, 0x00, 0xEC, 0x00, 0x5D]+ , GetCase+ "getByteArray"+ (getByteArray 3)+ (Just (3, 1, byteArrayFromList @Word8 [0xFD, 0x6E, 0xEC]))+ [0xFD, 0x6E, 0xEC, 0x5D]+ , GetCase+ "getLiftedPrimArray"+ (getLiftedPrimArray (Proxy :: Proxy Word16LE) 3)+ (Just (6, 1, liftedPrimArrayFromList @Word16LE [0xFD, 0x6E, 0xEC]))+ [0xFD, 0x00, 0x6E, 0x00, 0xEC, 0x00, 0x5D] , GetCase "StaBytes" (get @StaBytes) (Just (2, 1, mkStaBytes "hi")) [0x68, 0x69, 0x21] , GetCase "TagFoo (one)" (get @TagFoo) (Just (2, 0, TagFooOne 7)) [0x00, 0x07] , GetCase "TagFoo (two)" (get @TagFoo) (Just (3, 0, TagFooTwo 7)) [0x01, 0x07, 0x00]@@ -400,8 +427,12 @@ , GetCase "TB16 1" (get @TermBytes16) (Just (2, 0, TermBytes16 (BSS.pack [1]))) [1, 0] , GetCase "TB16 2" (get @TermBytes16) (Just (4, 0, TermBytes16 (BSS.pack [1, 2]))) [1, 2, 0, 0] , GetCase "TB16 3" (get @TermBytes16) (Just (4, 0, TermBytes16 (BSS.pack [1, 2, 3]))) [1, 2, 3, 0]- , GetCase "Seq Word16LE" (get @(Seq Word16LE)) (Just (12, 0, Seq.fromList [0xEC, 0x5D])) [2, 0, 0, 0, 0, 0, 0, 0, 0xEC, 0, 0x5D, 0] , GetCase+ "Seq Word16LE"+ (get @(Seq Word16LE))+ (Just (12, 0, Seq.fromList [0xEC, 0x5D]))+ [2, 0, 0, 0, 0, 0, 0, 0, 0xEC, 0, 0x5D, 0]+ , GetCase "Seq WordX" (get @(Seq WordX)) (Just (18, 0, Seq.fromList [WordX32 0, WordX32 0]))@@ -433,8 +464,14 @@ , PutCase "Int64BE" (putInt64BE 0x5DEC6EFD12345678) [0x5D, 0xEC, 0x6E, 0xFD, 0x12, 0x34, 0x56, 0x78] , PutCase "FloatLE" (putFloatLE (FloatLE (castWord32ToFloat 0x5DEC6EFD))) [0xFD, 0x6E, 0xEC, 0x5D] , PutCase "FloatBE" (putFloatBE (FloatBE (castWord32ToFloat 0x5DEC6EFD))) [0x5D, 0xEC, 0x6E, 0xFD]- , PutCase "DoubleLE" (putDoubleLE (DoubleLE (castWord64ToDouble 0x5DEC6EFD12345678))) [0x78, 0x56, 0x34, 0x12, 0xFD, 0x6E, 0xEC, 0x5D]- , PutCase "DoubleBE" (putDoubleBE (DoubleBE (castWord64ToDouble 0x5DEC6EFD12345678))) [0x5D, 0xEC, 0x6E, 0xFD, 0x12, 0x34, 0x56, 0x78]+ , PutCase+ "DoubleLE"+ (putDoubleLE (DoubleLE (castWord64ToDouble 0x5DEC6EFD12345678)))+ [0x78, 0x56, 0x34, 0x12, 0xFD, 0x6E, 0xEC, 0x5D]+ , PutCase+ "DoubleBE"+ (putDoubleBE (DoubleBE (castWord64ToDouble 0x5DEC6EFD12345678)))+ [0x5D, 0xEC, 0x6E, 0xFD, 0x12, 0x34, 0x56, 0x78] , PutCase "ShortByteString" (putByteString (BSS.pack [0xEC, 0x5D])) [0xEC, 0x5D] , PutCase "Text" (putText "hi") [0x68, 0x69] , PutCase "Two Word8" (putWord8 0x5D *> putWord8 0xBB) [0x5D, 0xBB]@@ -447,7 +484,10 @@ , PutCase "BoolByte True" (put (BoolByte True)) [0x01] , PutCase "BoolByte False" (put (BoolByte False)) [0x00] , PutCase "putByteArray" (putByteArray (byteArrayFromList @Word8 [0xFD, 0x6E, 0xEC])) [0xFD, 0x6E, 0xEC]- , PutCase "putLiftedPrimArray" (putLiftedPrimArray (liftedPrimArrayFromList @Word16LE [0xFD, 0x6E, 0xEC])) [0xFD, 0x00, 0x6E, 0x00, 0xEC, 0x00]+ , PutCase+ "putLiftedPrimArray"+ (putLiftedPrimArray (liftedPrimArrayFromList @Word16LE [0xFD, 0x6E, 0xEC]))+ [0xFD, 0x00, 0x6E, 0x00, 0xEC, 0x00] , PutCase "StaBytes" (put (mkStaBytes "hi")) [0x68, 0x69] , PutCase "StaBytes (less)" (put (mkStaBytes "h")) [0x68, 0x00] , PutCase "StaBytes (more)" (put (mkStaBytes "hi!")) [0x68, 0x69]@@ -541,7 +581,8 @@ gen16 = fmap (WordX16 . Word16LE) (FG.inRange (FR.between (0, maxBound))) gen32 = fmap (WordX32 . Word32LE) (FG.inRange (FR.between (0, maxBound))) -takeDiff :: (CaseTarget z) => z -> ByteCount -> ByteCount -> ByteCount -> [ByteCount] -> IO ([ByteCount], (ByteCount, z))+takeDiff+ :: (CaseTarget z) => z -> ByteCount -> ByteCount -> ByteCount -> [ByteCount] -> IO ([ByteCount], (ByteCount, z)) takeDiff z pos had diff = go 0 where go !acc = \case