streaming-bytestring 0.2.2 → 0.2.3
raw patch · 4 files changed
+24/−1 lines, 4 files
Files
- CHANGELOG.md +6/−0
- lib/Streaming/ByteString.hs +12/−0
- streaming-bytestring.cabal +1/−1
- tests/Test.hs +5/−0
CHANGELOG.md view
@@ -1,3 +1,9 @@+## 0.2.3 (2022-08-18)++#### Added++- Add `for :: Monad m => ByteStream m r -> (P.ByteString -> ByteStream m r) -> ByteStream m r`+ ## 0.2.2 (2022-05-18) #### Changed
lib/Streaming/ByteString.hs view
@@ -72,6 +72,7 @@ -- * Transforming ByteStreams , map+ , for , intercalate , intersperse @@ -638,6 +639,17 @@ map :: Monad m => (Word8 -> Word8) -> ByteStream m r -> ByteStream m r map f z = dematerialize z Empty (Chunk . B.map f) Go {-# INLINE map #-}++-- | @'for' xs f@ applies @f@ to each chunk in the stream, and+-- concatenates the resulting streams.+--+-- @since 0.2.3+for :: Monad m => ByteStream m r -> (P.ByteString -> ByteStream m r) -> ByteStream m r+for stream f = case stream of+ Empty r -> Empty r+ Chunk bs bss -> f bs *> for bss f+ Go m -> Go ((`for` f) <$> m)+{-# INLINE for #-} -- -- | /O(n)/ 'reverse' @xs@ returns the elements of @xs@ in reverse order. -- reverse :: ByteString -> ByteString
streaming-bytestring.cabal view
@@ -1,6 +1,6 @@ cabal-version: >=1.10 name: streaming-bytestring-version: 0.2.2+version: 0.2.3 synopsis: Fast, effectful byte streams. description: This library enables fast and safe streaming of byte data, in either @Word8@ or
tests/Test.hs view
@@ -370,6 +370,11 @@ unpackToString (Q8.concat (Q8.lineSplit n (fromString str))) == str , testProperty "concat after lineSplit round trips (CRLF)" $ over ((,) <$> nats <~> strSeriesCrlf) $ \(n,str) -> unpackToString (Q8.concat (Q8.lineSplit n (fromString str))) == str+ , testProperty "'for' is equivalent to the one in streaming" $ over chunksSeries $ \ss ->+ let doubleStream b = S.each [b, b]+ doubleByteStream b = Q.chunk b *> Q.chunk b+ in unpackToString (Q.fromChunks (S.for (Q.toChunks (fromChunks ss)) doubleStream))+ == unpackToString (Q.for (fromChunks ss) doubleByteStream) ] , testGroup "Unit Tests" [ testCase "hGetContents: Handle stays open" handleIsOpen