@@ -269,9 +269,9 @@ module Streamly.Internal.Prelude
269269 , reverse'
270270
271271 -- ** Parsing
272− , splitParse
273− , splitParseTill
274− , concatParse
272+ , parseMany
273+ , parseManyTill
274+ , parseIterate
275275
276276 -- ** Trimming
277277 , take
@@ -3142,13 +3142,8 @@ concatMapTreeYieldLeavesWith combine f = concatMapLoopWith combine f yield
31423142------------------------------------------------------------------------------
31433143
31443144-- Splitting operations that take a predicate and a Fold can be
3145−-- expressed using splitParse. Operations like chunksOf, intervalsOf, split*,
3146−-- can be expressed using splitParse when used with an appropriate Parse.
3147−--
3148−-- The name splitParse is supposed to be opposite of concatMap. Alternative
3149−-- names could be "many", "parseMany" or "splitMany"? If we are going to have a
3150−-- separate combinators for Fold and Parser then having fold/parse in the name
3151−-- allows the distinction.
3145+-- expressed using parseMany. Operations like chunksOf, intervalsOf, split*,
3146+-- can be expressed using parseMany when used with an appropriate Parser.
31523147--
31533148-- XXX We need takeGE/takeBetween to implement "some" using "many".
31543149
@@ -3158,24 +3153,24 @@ concatMapTreeYieldLeavesWith combine f = concatMapLoopWith combine f yield
31583153-- This is the streaming equivalent of the 'Streamly.Internal.Data.Parser.many'
31593154-- parse combinator.
31603155--
3161−-- >>> S.toList $ S.splitParse (PR.take 2 $ PR.fromFold FL.sum) $ S.fromList [1..10]
3156+-- >>> S.toList $ S.parseMany (PR.take 2 $ PR.fromFold FL.sum) $ S.fromList [1..10]
31623157-- > [3,7,11,15,19]
31633158--
3164−-- >>> S.toList $ S.splitParse (PR.line FL.toList) $ S.fromList "hello\nworld"
3159+-- >>> S.toList $ S.parseMany (PR.line FL.toList) $ S.fromList "hello\nworld"
31653160-- > ["hello\n","world"]
31663161--
31673162-- /Internal
31683163--
3169−{-# INLINE splitParse #-}
3170−splitParse
3164+{-# INLINE parseMany #-}
3165+parseMany
31713166 :: (IsStream t, MonadThrow m)
31723167 => Parser m a b
31733168 -> t m a
31743169 -> t m b
3175−splitParse p m =
3176− D.fromStreamD $ D.splitParse (PRD.fromParserK p) (D.toStreamD m)
3170+parseMany p m =
3171+ D.fromStreamD $ D.parseMany (PRD.fromParserK p) (D.toStreamD m)
31773172
3178−-- | @splitParseTill collect test stream@ tries the parser @test@ on the input,
3173+-- | @parseManyTill collect test stream@ tries the parser @test@ on the input,
31793174-- if @test@ fails it backtracks and tries @collect@, after @collect@ succeeds
31803175-- @test@ is tried again and so on. The parser stops when @test@ succeeds. The
31813176-- output of @test@ is discarded and the output of @collect@ is emitted in the
@@ -3183,22 +3178,20 @@ splitParse p m =
31833178--
31843179-- /Unimplemented/
31853180--
3186−{-# INLINE splitParseTill #-}
3187−splitParseTill ::
3181+{-# INLINE parseManyTill #-}
3182+parseManyTill ::
31883183 -- (IsStream t, MonadThrow m) =>
31893184 Parser m a b
31903185 -> Parser m a x
31913186 -> t m a
31923187 -> t m b
3193−splitParseTill = undefined
3188+parseManyTill = undefined
31943189
3195−-- Rename to iterateParse?
3196−--
31973190-- | Iterate a parser generating function on a stream. The initial value @b@ is
31983191-- used to generate the first parser, the parser is applied on the stream and
31993192-- the result is used to generate the next parser and so on.
32003193--
3201−-- >>> S.toList $ S.map getSum $ S.concatParse (\b -> PR.take 2 (FL.mconcatTo b)) 0 $ S.map Sum $ S.fromList [1..10]
3194+-- >>> S.toList $ S.map getSum $ S.parseIterate (\b -> PR.take 2 (FL.mconcatTo b)) 0 $ S.map Sum $ S.fromList [1..10]
32023195-- > [3,10,21,36,55,55]
32033196--
32043197-- This is the streaming equivalent of monad like sequenced application of
@@ -3206,15 +3199,15 @@ splitParseTill = undefined
32063199--
32073200-- /Internal/
32083201--
3209−{-# INLINE concatParse #-}
3210−concatParse
3202+{-# INLINE parseIterate #-}
3203+parseIterate
32113204 :: (IsStream t, MonadThrow m)
32123205 => (b -> Parser m a b)
32133206 -> b
32143207 -> t m a
32153208 -> t m b
3216−concatParse f i m = D.fromStreamD $
3217− D.concatParse (\b -> PRD.fromParserK $ f b) i (D.toStreamD m)
3209+parseIterate f i m = D.fromStreamD $
3210+ D.parseIterate (\b -> PRD.fromParserK $ f b) i (D.toStreamD m)
32183211
32193212------------------------------------------------------------------------------
32203213-- Grouping/Splitting