packages feed

hw-prim 0.6.2.6 → 0.6.2.7

raw patch · 4 files changed

+21/−23 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- HaskellWorks.Data.ByteString: rechunkSegments :: Int -> [ByteString] -> [ByteString]
- HaskellWorks.Data.ByteString: rechunkSegmentsPadded :: Int -> [ByteString] -> [ByteString]
- HaskellWorks.Data.ByteString.Lazy: rechunkSegments :: Int -> ByteString -> ByteString
- HaskellWorks.Data.ByteString.Lazy: rechunkSegmentsPadded :: Int -> ByteString -> ByteString
+ HaskellWorks.Data.ByteString: resegment :: Int -> [ByteString] -> [ByteString]
+ HaskellWorks.Data.ByteString: resegmentPadded :: Int -> [ByteString] -> [ByteString]
+ HaskellWorks.Data.ByteString.Lazy: resegment :: Int -> ByteString -> ByteString
+ HaskellWorks.Data.ByteString.Lazy: resegmentPadded :: Int -> ByteString -> ByteString

Files

hw-prim.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack  name:           hw-prim-version:        0.6.2.6+version:        0.6.2.7 synopsis:       Primitive functions and data types description:    Primitive functions and data types. category:       Data
src/HaskellWorks/Data/ByteString.hs view
@@ -3,8 +3,8 @@ module HaskellWorks.Data.ByteString   ( chunkedBy   , ToByteString(..)-  , rechunkSegments-  , rechunkSegmentsPadded+  , resegment+  , resegmentPadded   ) where  import Data.Semigroup ((<>))@@ -49,8 +49,8 @@     (as, zs) -> as : chunkedBy n zs {-# INLINE chunkedBy #-} -rechunkSegments :: Int -> [BS.ByteString] -> [BS.ByteString]-rechunkSegments multiple = go+resegment :: Int -> [BS.ByteString] -> [BS.ByteString]+resegment multiple = go   where go (bs:bss) = case BS.length bs of               bsLen -> if bsLen < multiple                 then case multiple - bsLen of@@ -66,8 +66,8 @@                     else BS.take bsCroppedLen bs:go (BS.drop bsCroppedLen bs:bss)         go [] = [] -rechunkSegmentsPadded :: Int -> [BS.ByteString] -> [BS.ByteString]-rechunkSegmentsPadded multiple = go+resegmentPadded :: Int -> [BS.ByteString] -> [BS.ByteString]+resegmentPadded multiple = go   where go (bs:bss) = case BS.length bs of               bsLen -> if bsLen < multiple                 then case multiple - bsLen of@@ -82,4 +82,3 @@                     then bs:go bss                     else BS.take bsCroppedLen bs:go (BS.drop bsCroppedLen bs:bss)         go [] = []-
src/HaskellWorks/Data/ByteString/Lazy.hs view
@@ -2,8 +2,8 @@  module HaskellWorks.Data.ByteString.Lazy   ( ToLazyByteString(..)-  , rechunkSegments-  , rechunkSegmentsPadded+  , resegment+  , resegmentPadded   ) where  import Data.Word@@ -52,8 +52,8 @@   toLazyByteString vs = LBS.fromChunks (toByteString <$> vs)   {-# INLINE toLazyByteString #-} -rechunkSegments :: Int -> LBS.ByteString -> LBS.ByteString-rechunkSegments multiple = LBS.fromChunks . BS.rechunkSegments multiple . LBS.toChunks+resegment :: Int -> LBS.ByteString -> LBS.ByteString+resegment multiple = LBS.fromChunks . BS.resegment multiple . LBS.toChunks -rechunkSegmentsPadded :: Int -> LBS.ByteString -> LBS.ByteString-rechunkSegmentsPadded multiple = LBS.fromChunks . BS.rechunkSegmentsPadded multiple . LBS.toChunks+resegmentPadded :: Int -> LBS.ByteString -> LBS.ByteString+resegmentPadded multiple = LBS.fromChunks . BS.resegmentPadded multiple . LBS.toChunks
test/HaskellWorks/Data/ByteStringSpec.hs view
@@ -15,24 +15,23 @@  spec :: Spec spec = describe "HaskellWorks.Data.ByteStringSpec" $ do-  it "rechunkSegments does not modify data" $ requireProperty $ do+  it "resegment does not modify data" $ requireProperty $ do     bss       <- forAll $ (BS.pack <$>) <$> G.list (R.linear 0 8) (G.list (R.linear 0 24) (G.word8 R.constantBounded))     chunkSize <- forAll $ G.int (R.linear 1 4)-    mconcat (BS.rechunkSegments chunkSize bss) === mconcat bss-  it "rechunkSegments creates correctly sized segments" $ requireProperty $ do+    mconcat (BS.resegment chunkSize bss) === mconcat bss+  it "resegment creates correctly sized segments" $ requireProperty $ do     bss       <- forAll $ (BS.pack <$>) <$> G.list (R.linear 0 8) (G.list (R.linear 0 24) (G.word8 R.constantBounded))     chunkSize <- forAll $ G.int (R.linear 1 4)-    forM_ (drop 1 (reverse (BS.rechunkSegments chunkSize bss))) $ \bs -> do+    forM_ (drop 1 (reverse (BS.resegment chunkSize bss))) $ \bs -> do       (BS.length bs) `mod` chunkSize === 0-  it "rechunkSegmentsPadded does not modify data" $ requireProperty $ do+  it "resegmentPadded does not modify data" $ requireProperty $ do     bss       <- forAll $ (BS.pack <$>) <$> G.list (R.linear 0 8) (G.list (R.linear 0 24) (G.word8 R.constantBounded))     chunkSize <- forAll $ G.int (R.linear 1 4)     elbs      <- forAll $ pure $ LBS.fromChunks bss-    albs      <- forAll $ pure $ LBS.take (LBS.length elbs) (LBS.fromChunks (BS.rechunkSegmentsPadded chunkSize bss))+    albs      <- forAll $ pure $ LBS.take (LBS.length elbs) (LBS.fromChunks (BS.resegmentPadded chunkSize bss))     albs === elbs-  it "rechunkSegmentsPadded creates correctly sized segments" $ requireProperty $ do+  it "resegmentPadded creates correctly sized segments" $ requireProperty $ do     bss       <- forAll $ (BS.pack <$>) <$> G.list (R.linear 0 8) (G.list (R.linear 0 24) (G.word8 R.constantBounded))     chunkSize <- forAll $ G.int (R.linear 1 4)-    forM_ (reverse (BS.rechunkSegmentsPadded chunkSize bss)) $ \bs -> do+    forM_ (reverse (BS.resegmentPadded chunkSize bss)) $ \bs -> do       (BS.length bs) `mod` chunkSize === 0-