on master help sign in
Use foldMany1 in chunksOf instead of foldMany
commitb6a07525ebfa20de50e9f5986f08a53c121a5184 authorHarendra Kumar <harendra@composewell.com> dateWed 27 Jan 2021, 18:22 (6 years ago) parenta41a7b5
3 files changed+6−5
benchmark/Streamly/Benchmark/FileSystem/Handle/Read.hs+2−2 benchmark/Streamly/Benchmark/FileSystem/Handle/ReadWrite.hs+2−2 src/Streamly/Internal/Data/Stream/StreamD/Type.hs+2−1
benchmark/Streamly/Benchmark/FileSystem/Handle/Read.hs+2−2
@@ -49,7 +49,7 @@ import Prelude hiding (last, length)
4949import Streamly.Benchmark.Common.Handle
5050
5151#ifdef INSPECTION
52−import Streamly.Internal.Data.Stream.StreamD.Type (Step(..), GroupState)
52+import Streamly.Internal.Data.Stream.StreamD.Type (Step(..), FoldMany1)
5353
5454import qualified Streamly.Internal.Data.Array.Foreign.Mut.Types as MA
5555import qualified Streamly.Internal.Data.Stream.StreamD as D
@@ -336,7 +336,7 @@ chunksOf n inh =
336336#ifdef INSPECTION
337337inspect $ hasNoTypeClasses 'chunksOf
338338inspect $ 'chunksOf `hasNoType` ''Step
339−inspect $ 'chunksOf `hasNoType` ''GroupState
339+inspect $ 'chunksOf `hasNoType` ''FoldMany1
340340inspect $ 'chunksOf `hasNoType` ''AT.ArrayUnsafe -- AT.writeNUnsafe
341341inspect $ 'chunksOf `hasNoType` ''IUF.ConcatState -- FH.read/UF.concat
342342inspect $ 'chunksOf `hasNoType` ''MA.ReadUState -- FH.read/A.read
benchmark/Streamly/Benchmark/FileSystem/Handle/ReadWrite.hs+2−2
@@ -112,7 +112,7 @@ inspect $ hasNoTypeClasses 'readFromBytesNull
112112inspect $ 'readFromBytesNull `hasNoType` ''Step
113113inspect $ 'readFromBytesNull `hasNoType` ''MAS.SpliceState
114114inspect $ 'readFromBytesNull `hasNoType` ''AT.ArrayUnsafe -- FH.fromBytes/S.arraysOf
115−inspect $ 'readFromBytesNull `hasNoType` ''D.GroupState
115+inspect $ 'readFromBytesNull `hasNoType` ''D.FoldMany1
116116#endif
117117
118118-- | Send the file contents ('defaultChunkSize') to /dev/null
@@ -126,7 +126,7 @@ inspect $ hasNoTypeClasses 'readWithBufferOfFromBytesNull
126126inspect $ 'readWithBufferOfFromBytesNull `hasNoType` ''Step
127127inspect $ 'readWithBufferOfFromBytesNull `hasNoType` ''MAS.SpliceState
128128inspect $ 'readWithBufferOfFromBytesNull `hasNoType` ''AT.ArrayUnsafe -- FH.fromBytes/S.arraysOf
129−inspect $ 'readWithBufferOfFromBytesNull `hasNoType` ''D.GroupState
129+inspect $ 'readWithBufferOfFromBytesNull `hasNoType` ''D.FoldMany1
130130#endif
131131
132132-- | Send the chunk content ('defaultChunkSize') to /dev/null
src/Streamly/Internal/Data/Stream/StreamD/Type.hs+2−1
@@ -78,6 +78,7 @@ module Streamly.Internal.Data.Stream.StreamD.Type
7878 , concatMap
7979 , concatMapM
8080 , FoldMany (..) -- for inspection testing
81+ , FoldMany1 (..)
8182 , foldMany
8283 , foldMany1
8384 , groupsOf2
@@ -904,7 +905,7 @@ foldMany1 (Fold fstep initial extract) (Stream step state) =
904905
905906{-# INLINE chunksOf #-}
906907chunksOf :: Monad m => Int -> Fold m a b -> Stream m a -> Stream m b
907−chunksOf n f = foldMany (FL.takeLE n f)
908+chunksOf n f = foldMany1 (FL.takeLE n f)
908909
909910data GroupState2 s fs
910911 = GroupStart2 s