on master help sign in
rename parseChunks to splitParse
f1eb9a1Harendra Kumar
benchmark/FileIO.hs+6−6
@@ -212,12 +212,12 @@ main = do
212 , mkBench "sumChunksOf 1" href $ do
212 , mkBench "sumChunksOf 1" href $ do
213 Handles inh _ <- readIORef href
213 Handles inh _ <- readIORef href
214 BFS.chunksOfSum 1 inh
214 BFS.chunksOfSum 1 inh
215− , mkBench "sumChunksOf (single chunk) (parseChunks)" href $ do
215+ , mkBench "sumChunksOf (single chunk) (splitParse)" href $ do
216 Handles inh _ <- readIORef href
216 Handles inh _ <- readIORef href
217− BFS.parseChunksOfSum fileSize inh
217+ BFS.splitParseChunksOfSum fileSize inh
218− , mkBench "sumChunksOf 1 (parseChunks)" href $ do
218+ , mkBench "sumChunksOf 1 (splitParse)" href $ do
219 Handles inh _ <- readIORef href
219 Handles inh _ <- readIORef href
220− BFS.parseChunksOfSum 1 inh
220+ BFS.splitParseChunksOfSum 1 inh
221
221
222 , mkBench "arraysOf 1" href $ do
222 , mkBench "arraysOf 1" href $ do
223 Handles inh _ <- readIORef href
223 Handles inh _ <- readIORef href
@@ -268,9 +268,9 @@ main = do
268 , mkBench "splitOnSuffix \\n (line count)" href $ do
268 , mkBench "splitOnSuffix \\n (line count)" href $ do
269 Handles inh _ <- readIORef href
269 Handles inh _ <- readIORef href
270 BFS.splitOnSuffix inh
270 BFS.splitOnSuffix inh
271− , mkBench "splitOn \\n (line count) (parseChunks)" href $ do
271+ , mkBench "splitOn \\n (line count) (splitParse)" href $ do
272 Handles inh _ <- readIORef href
272 Handles inh _ <- readIORef href
273− BFS.parseChunksSplitOn inh
273+ BFS.splitParseSepBy inh
274 , mkBench "wordsBy isSpace (word count)" href $ do
274 , mkBench "wordsBy isSpace (word count)" href $ do
275 Handles inh _ <- readIORef href
275 Handles inh _ <- readIORef href
276 BFS.wordsBy inh
276 BFS.wordsBy inh
benchmark/Streamly/Benchmark/FileIO/Stream.hs+11−11
@@ -57,12 +57,12 @@ module Streamly.Benchmark.FileIO.Stream
57 , decodeUtf8Lax
57 , decodeUtf8Lax
58 , copyCodecUtf8Lenient
58 , copyCodecUtf8Lenient
59 , chunksOfSum
59 , chunksOfSum
60− , parseChunksOfSum
60+ , splitParseChunksOfSum
61 , chunksOf
61 , chunksOf
62 , chunksOfD
62 , chunksOfD
63 , splitOn
63 , splitOn
64 , splitOnSuffix
64 , splitOnSuffix
65− , parseChunksSplitOn
65+ , splitParseSepBy
66 , wordsBy
66 , wordsBy
67 , splitOnSeq
67 , splitOnSeq
68 , splitOnSeqUtf8
68 , splitOnSeqUtf8
@@ -445,10 +445,10 @@ inspect $ 'chunksOfD `hasNoType` ''AT.FlattenState
445inspect $ 'chunksOfD `hasNoType` ''D.ConcatMapUState
445inspect $ 'chunksOfD `hasNoType` ''D.ConcatMapUState
446#endif
446#endif
447
447
448−{-# INLINE parseChunksOfSum #-}
448+{-# INLINE splitParseChunksOfSum #-}
449−parseChunksOfSum :: Int -> Handle -> IO Int
449+splitParseChunksOfSum :: Int -> Handle -> IO Int
450−parseChunksOfSum n inh =
450+splitParseChunksOfSum n inh =
451− S.length $ IP.parseChunks (IFL.take n FL.sum) (S.unfold FH.read inh)
451+ S.length $ IP.splitParse (IFL.take n FL.sum) (S.unfold FH.read inh)
452
452
453{-# INLINE linesUnlinesCopy #-}
453{-# INLINE linesUnlinesCopy #-}
454linesUnlinesCopy :: Handle -> Handle -> IO ()
454linesUnlinesCopy :: Handle -> Handle -> IO ()
@@ -609,11 +609,11 @@ inspect $ 'splitOnSuffix `hasNoType` ''D.ConcatMapUState
609#endif
609#endif
610
610
611-- | Split on line feed.
611-- | Split on line feed.
612−{-# INLINE parseChunksSplitOn #-}
612+{-# INLINE splitParseSepBy #-}
613−parseChunksSplitOn :: Handle -> IO Int
613+splitParseSepBy :: Handle -> IO Int
614−parseChunksSplitOn inh =
614+splitParseSepBy inh =
615− (S.length $ IP.parseChunks (PR.sepBy (== lf) FL.drain)
615+ (S.length $ IP.splitParse (PR.sepBy (== lf) FL.drain)
616− (S.unfold FH.read inh)) -- >>= print
616+ (S.unfold FH.read inh)) -- >>= print
617
617
618-- | Words by space
618-- | Words by space
619{-# INLINE wordsBy #-}
619{-# INLINE wordsBy #-}
src/Streamly/Internal/Data/Fold.hs+1−1
@@ -838,7 +838,7 @@ or = Fold (\x a -> return $ x || a) (return False) return
838-- Stops after @n@ elements.
838-- Stops after @n@ elements.
839-- Never fails.
839-- Never fails.
840--
840--
841−-- S.chunksOf n f = S.parseChunks (FL.take n f)
841+-- S.chunksOf n f = S.splitParse (FL.take n f)
842--
842--
843-- /Internal/
843-- /Internal/
844--
844--
src/Streamly/Internal/Data/Parser.hs+6−6
@@ -227,10 +227,10 @@ takeWhile predicate (Fold fstep finitial fextract) =
227-- >>> S.parse (PR.sepBy (== 1) FL.toList) $ S.fromList [0,0,1,0,1]
227-- >>> S.parse (PR.sepBy (== 1) FL.toList) $ S.fromList [0,0,1,0,1]
228-- > Right [0,0]
228-- > Right [0,0]
229--
229--
230−-- >>> S.toList $ S.parseChunks (PR.sepBy (== 1) FL.toList) $ S.fromList [0,0,1,0,1]
230+-- >>> S.toList $ S.splitParse (PR.sepBy (== 1) FL.toList) $ S.fromList [0,0,1,0,1]
231-- > [[0,0],[0],[]]
231-- > [[0,0],[0],[]]
232--
232--
233−-- S.splitOn pred f = S.parseChunks (PR.sepBy pred f)
233+-- S.splitOn pred f = S.splitParse (PR.sepBy pred f)
234--
234--
235-- /Internal/
235-- /Internal/
236--
236--
@@ -256,7 +256,7 @@ sepBy predicate (Fold fstep finitial fextract) =
256-- * Stops - when the predicate succeeds.
256-- * Stops - when the predicate succeeds.
257-- * Fails - never.
257-- * Fails - never.
258--
258--
259−-- S.splitWithSuffix pred f = S.parseChunks (PR.sepWithSuffix pred f)
259+-- S.splitWithSuffix pred f = S.splitParse (PR.sepWithSuffix pred f)
260--
260--
261-- /Unimplemented/
261-- /Unimplemented/
262--
262--
@@ -272,7 +272,7 @@ sepWithSuffix = undefined
272-- * Stops - when the predicate succeeds.
272-- * Stops - when the predicate succeeds.
273-- * Fails - never.
273-- * Fails - never.
274--
274--
275−-- S.splitWithPrefix pred f = S.parseChunks (PR.sepWithPrefix pred f)
275+-- S.splitWithPrefix pred f = S.splitParse (PR.sepWithPrefix pred f)
276--
276--
277-- /Unimplemented/
277-- /Unimplemented/
278--
278--
@@ -316,7 +316,7 @@ sepByMax predicate count (Fold fstep finitial fextract) =
316-- * Stops - when it finds a word separator after a non-word element
316-- * Stops - when it finds a word separator after a non-word element
317-- * Fails - never.
317-- * Fails - never.
318--
318--
319−-- S.wordsBy pred f = S.parseChunks (PR.wordBy pred f)
319+-- S.wordsBy pred f = S.splitParse (PR.wordBy pred f)
320--
320--
321-- /Unimplemented/
321-- /Unimplemented/
322--
322--
@@ -336,7 +336,7 @@ wordBy = undefined
336-- * Stops - when the group ends.
336-- * Stops - when the group ends.
337-- * Fails - never.
337-- * Fails - never.
338--
338--
339−-- S.groupsBy cmp f = S.parseChunks (PR.groupBy cmp f)
339+-- S.groupsBy cmp f = S.splitParse (PR.groupBy cmp f)
340--
340--
341-- /Unimplemented/
341-- /Unimplemented/
342--
342--
src/Streamly/Internal/Data/Stream/StreamD.hs+5−5
@@ -129,7 +129,7 @@ module Streamly.Internal.Data.Stream.StreamD
129 , runFold
129 , runFold
130
130
131 , parselMx'
131 , parselMx'
132− , parseChunks
132+ , splitParse
133
133
134 -- ** Specialized Folds
134 -- ** Specialized Folds
135 , tap
135 , tap
@@ -953,7 +953,7 @@ foldlS fstep begin (Stream step state) = Stream step' (Left (state, begin))
953------------------------------------------------------------------------------
953------------------------------------------------------------------------------
954
954
955-- Inlined definition. Without the inline "serially/parser/take" benchmark
955-- Inlined definition. Without the inline "serially/parser/take" benchmark
956−-- degrades and parseChunks does not fuse. Even using "inline" at the callsite
956+-- degrades and splitParse does not fuse. Even using "inline" at the callsite
957-- does not help.
957-- does not help.
958{-# INLINE splitAt #-}
958{-# INLINE splitAt #-}
959splitAt :: Int -> [a] -> ([a],[a])
959splitAt :: Int -> [a] -> ([a],[a])
@@ -1034,13 +1034,13 @@ data ParseChunksState x inpBuf st pst =
1034 | ParseChunksBuf inpBuf st inpBuf pst
1034 | ParseChunksBuf inpBuf st inpBuf pst
1035 | ParseChunksYield x (ParseChunksState x inpBuf st pst)
1035 | ParseChunksYield x (ParseChunksState x inpBuf st pst)
1036
1036
1037−{-# INLINE_NORMAL parseChunks #-}
1037+{-# INLINE_NORMAL splitParse #-}
1038−parseChunks
1038+splitParse
1039 :: Monad m
1039 :: Monad m
1040 => Parser m a b
1040 => Parser m a b
1041 -> Stream m a
1041 -> Stream m a
1042 -> Stream m b
1042 -> Stream m b
1043−parseChunks (Parser pstep initial extract) (Stream step state) =
1043+splitParse (Parser pstep initial extract) (Stream step state) =
1044 Stream stepOuter (ParseChunksInit [] state)
1044 Stream stepOuter (ParseChunksInit [] state)
1045
1045
1046 where
1046 where
src/Streamly/Internal/Prelude.hs+8−8
@@ -267,7 +267,7 @@ module Streamly.Internal.Prelude
267 , reverse'
267 , reverse'
268
268
269 -- ** Parsing
269 -- ** Parsing
270− , parseChunks
270+ , splitParse
271
271
272 -- ** Trimming
272 -- ** Trimming
273 , take
273 , take
@@ -3114,25 +3114,25 @@ concatMapTreeYieldLeavesWith combine f = concatMapLoopWith combine f yield
3114------------------------------------------------------------------------------
3114------------------------------------------------------------------------------
3115
3115
3116-- Splitting operations that take a predicate and a Fold can be
3116-- Splitting operations that take a predicate and a Fold can be
3117−-- expressed using parseChunks. Operations like chunksOf, intervalsOf, split*,
3117+-- expressed using splitParse. Operations like chunksOf, intervalsOf, split*,
3118−-- can be expressed using parseChunks when used with an appropriate Parse.
3118+-- can be expressed using splitParse when used with an appropriate Parse.
3119--
3119--
3120-- | Apply a 'Parse' repeatedly on a stream and emit the parsed values in the
3120-- | Apply a 'Parse' repeatedly on a stream and emit the parsed values in the
3121-- output stream.
3121-- output stream.
3122--
3122--
3123−-- >>> S.toList $ S.parseChunks (PR.take 2 $ PR.fromFold FL.sum) $ S.fromList [1..10]
3123+-- >>> S.toList $ S.splitParse (PR.take 2 $ PR.fromFold FL.sum) $ S.fromList [1..10]
3124-- > [3,7,11,15,19]
3124-- > [3,7,11,15,19]
3125--
3125--
3126−-- >>> S.toList $ S.parseChunks (PR.line FL.toList) $ S.fromList "hello\nworld"
3126+-- >>> S.toList $ S.splitParse (PR.line FL.toList) $ S.fromList "hello\nworld"
3127-- > ["hello\n","world"]
3127-- > ["hello\n","world"]
3128--
3128--
3129−{-# INLINE parseChunks #-}
3129+{-# INLINE splitParse #-}
3130−parseChunks
3130+splitParse
3131 :: (IsStream t, Monad m)
3131 :: (IsStream t, Monad m)
3132 => Parser m a b
3132 => Parser m a b
3133 -> t m a
3133 -> t m a
3134 -> t m b
3134 -> t m b
3135−parseChunks f m = D.fromStreamD $ D.parseChunks f (D.toStreamD m)
3135+splitParse f m = D.fromStreamD $ D.splitParse f (D.toStreamD m)
3136
3136
3137------------------------------------------------------------------------------
3137------------------------------------------------------------------------------
3138-- Grouping/Splitting
3138-- Grouping/Splitting