on master help sign in
Change the argument order of Unfold.many
3012ae9Ranjeet Kumar Ranjan
benchmark/Streamly/Benchmark/FileSystem/Handle/ReadWrite.hs+2−2
@@ -135,7 +135,7 @@ _readChunks inh devNull = IUF.fold fld unf inh
135 where
135 where
136
136
137 fld = FH.write devNull
137 fld = FH.write devNull
138− unf = IUF.many FH.readChunks A.read
138+ unf = IUF.many A.read FH.readChunks
139
139
140-- | Send the chunk content to /dev/null
140-- | Send the chunk content to /dev/null
141-- Implicitly benchmarked via 'readWithBufferOfFromBytesNull'
141-- Implicitly benchmarked via 'readWithBufferOfFromBytesNull'
@@ -145,7 +145,7 @@ _readChunksWithBufferOf inh devNull = IUF.fold fld unf (defaultChunkSize, inh)
145 where
145 where
146
146
147 fld = FH.write devNull
147 fld = FH.write devNull
148− unf = IUF.many FH.readChunksWithBufferOf A.read
148+ unf = IUF.many A.read FH.readChunksWithBufferOf
149
149
150
150
151o_1_space_copy_fromBytes :: BenchEnv -> [Benchmark]
151o_1_space_copy_fromBytes :: BenchEnv -> [Benchmark]
core/src/Streamly/Internal/Data/Unfold/Type.hs+2−2
@@ -572,8 +572,8 @@ data ConcatState s1 s2 = ConcatOuter s1 | ConcatInner s1 s2
572-- /Since: 0.8.0/
572-- /Since: 0.8.0/
573--
573--
574{-# INLINE_NORMAL many #-}
574{-# INLINE_NORMAL many #-}
575−many :: Monad m => Unfold m a b -> Unfold m b c -> Unfold m a c
575+many :: Monad m => Unfold m b c -> Unfold m a b -> Unfold m a c
576−many (Unfold step1 inject1) (Unfold step2 inject2) = Unfold step inject
576+many (Unfold step2 inject2) (Unfold step1 inject1) = Unfold step inject
577
577
578 where
578 where
579
579
src/Streamly/Internal/FileSystem/File.hs+1−1
@@ -293,7 +293,7 @@ readWithBufferOf = usingFile2 FH.readWithBufferOf
293-- @since 0.7.0
293-- @since 0.7.0
294{-# INLINE read #-}
294{-# INLINE read #-}
295read :: (MonadCatch m, MonadAsync m) => Unfold m FilePath Word8
295read :: (MonadCatch m, MonadAsync m) => Unfold m FilePath Word8
296−read = UF.many (usingFile FH.readChunks) A.read
296+read = UF.many A.read (usingFile FH.readChunks)
297
297
298-- | Generate a stream of bytes from a file specified by path. The stream ends
298-- | Generate a stream of bytes from a file specified by path. The stream ends
299-- when EOF is encountered. File is locked using multiple reader and single
299-- when EOF is encountered. File is locked using multiple reader and single
src/Streamly/Internal/FileSystem/Handle.hs+3−3
@@ -343,12 +343,12 @@ readChunks = UF.supplyFirst defaultChunkSize readChunksWithBufferOf
343-- | Unfolds the tuple @(bufsize, handle)@ into a byte stream, read requests
343-- | Unfolds the tuple @(bufsize, handle)@ into a byte stream, read requests
344-- to the IO device are performed using buffers of @bufsize@.
344-- to the IO device are performed using buffers of @bufsize@.
345--
345--
346−-- >>> readWithBufferOf = Unfold.many Handle.readChunksWithBufferOf Array.read
346+-- >>> readWithBufferOf = Unfold.many Array.read Handle.readChunksWithBufferOf
347--
347--
348-- @since 0.7.0
348-- @since 0.7.0
349{-# INLINE readWithBufferOf #-}
349{-# INLINE readWithBufferOf #-}
350readWithBufferOf :: MonadIO m => Unfold m (Int, Handle) Word8
350readWithBufferOf :: MonadIO m => Unfold m (Int, Handle) Word8
351−readWithBufferOf = UF.many readChunksWithBufferOf A.read
351+readWithBufferOf = UF.many A.read readChunksWithBufferOf
352
352
353-- | @toBytesWithBufferOf bufsize handle@ reads a byte stream from a file
353-- | @toBytesWithBufferOf bufsize handle@ reads a byte stream from a file
354-- handle, reads are performed in chunks of up to @bufsize@.
354-- handle, reads are performed in chunks of up to @bufsize@.
@@ -373,7 +373,7 @@ toBytesWithBufferOf size h = AS.concat $ toChunksWithBufferOf size h
373-- @since 0.7.0
373-- @since 0.7.0
374{-# INLINE read #-}
374{-# INLINE read #-}
375read :: MonadIO m => Unfold m Handle Word8
375read :: MonadIO m => Unfold m Handle Word8
376−read = UF.many readChunks A.read
376+read = UF.many A.read readChunks
377
377
378-- | Generate a byte stream from a file 'Handle'.
378-- | Generate a byte stream from a file 'Handle'.
379--
379--
src/Streamly/Internal/Network/Inet/TCP.hs+1−1
@@ -314,7 +314,7 @@ withConnection addr port =
314{-# INLINE read #-}
314{-# INLINE read #-}
315read :: (MonadCatch m, MonadAsync m)
315read :: (MonadCatch m, MonadAsync m)
316 => Unfold m ((Word8, Word8, Word8, Word8), PortNumber) Word8
316 => Unfold m ((Word8, Word8, Word8, Word8), PortNumber) Word8
317−read = UF.many (usingConnection ISK.readChunks) A.read
317+read = UF.many A.read (usingConnection ISK.readChunks)
318
318
319-- | Read a stream from the supplied IPv4 host address and port number.
319-- | Read a stream from the supplied IPv4 host address and port number.
320--
320--
src/Streamly/Internal/Network/Socket.hs+1−1
@@ -430,7 +430,7 @@ toBytes = AS.concat . toChunks
430-- @since 0.7.0
430-- @since 0.7.0
431{-# INLINE readWithBufferOf #-}
431{-# INLINE readWithBufferOf #-}
432readWithBufferOf :: MonadIO m => Unfold m (Int, Socket) Word8
432readWithBufferOf :: MonadIO m => Unfold m (Int, Socket) Word8
433−readWithBufferOf = UF.many readChunksWithBufferOf A.read
433+readWithBufferOf = UF.many A.read readChunksWithBufferOf
434
434
435-- | Unfolds a 'Socket' into a byte stream. IO requests to the socket are
435-- | Unfolds a 'Socket' into a byte stream. IO requests to the socket are
436-- performed in sizes of
436-- performed in sizes of
test/Streamly/Test/Data/Unfold.hs+1−1
@@ -545,7 +545,7 @@ concat :: Bool
545concat =
545concat =
546 let unfIn = UF.replicateM 10
546 let unfIn = UF.replicateM 10
547 unfOut = UF.map return UF.enumerateFromToIntegral
547 unfOut = UF.map return UF.enumerateFromToIntegral
548− unf = UF.many unfOut unfIn
548+ unf = UF.many unfIn unfOut
549 lst = Prelude.concat $ Prelude.map (Prelude.replicate 10) [1 .. 10]
549 lst = Prelude.concat $ Prelude.map (Prelude.replicate 10) [1 .. 10]
550 in testUnfoldD unf (1, 10) lst
550 in testUnfoldD unf (1, 10) lst
551
551