on master help sign in
Change ParserD.manyTill signature, move Fold at end (#1900)
commitf390e53fca1febe655656e0233d0f5ab90c20842 authorRanjeet Ranjan <ranjeetr@composewell.com> dateFri 7 Oct 2022, 20:04 (4 years ago) parentda36a01
3 files changed+8−8
benchmark/Streamly/Benchmark/Data/Parser/ParserD.hs+1−1 core/src/Streamly/Internal/Data/Parser.hs+3−3 core/src/Streamly/Internal/Data/Parser/ParserD.hs+4−4
benchmark/Streamly/Benchmark/Data/Parser/ParserD.hs+1−1
@@ -143,7 +143,7 @@ manyTill :: MonadThrow m => Int -> Stream m Int -> m Int
143143manyTill value =
144144 let p = PR.satisfy (> 0)
145145 pcond = PR.satisfy (== value)
146− in Stream.parseD (PR.manyTill Fold.length p pcond)
146+ in Stream.parseD (PR.manyTill p pcond Fold.length)
147147
148148{-# INLINE serialWith #-}
149149serialWith :: MonadThrow m
core/src/Streamly/Internal/Data/Parser.hs+3−3
@@ -1384,7 +1384,7 @@ manyTillP :: -- Monad m =>
13841384manyTillP _p1 _p2 _f = undefined
13851385 -- D.toParserK $ D.manyTillP (D.fromParserK p1) (D.fromParserK p2) f
13861386
1387−-- | @manyTill f test collect@ tries the parser @test@ on the input, if @test@
1387+-- | @manyTill collect test f@ tries the parser @test@ on the input, if @test@
13881388-- fails it backtracks and tries @collect@, after @collect@ succeeds @test@ is
13891389-- tried again and so on. The parser stops when @test@ succeeds. The output of
13901390-- @test@ is discarded and the output of @collect@ is accumulated by the
@@ -1397,8 +1397,8 @@ manyTillP _p1 _p2 _f = undefined
13971397{-# INLINE manyTill #-}
13981398manyTill :: Monad m
13991399 => Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
1400−manyTill p1 p2 f =
1401− D.toParserK $ D.manyTill f (D.fromParserK p1) (D.fromParserK p2)
1400+manyTill collect test f =
1401+ D.toParserK $ D.manyTill (D.fromParserK collect) (D.fromParserK test) f
14021402
14031403-- | @manyThen f collect recover@ repeats the parser @collect@ on the input and
14041404-- collects the output in the supplied fold. If the the parser @collect@ fails,
core/src/Streamly/Internal/Data/Parser/ParserD.hs+4−4
@@ -2158,10 +2158,10 @@ data ManyTillState fs sr sl
21582158--
21592159{-# INLINE manyTill #-}
21602160manyTill :: Monad m
2161− => Fold m b c -> Parser m a b -> Parser m a x -> Parser m a c
2162−manyTill (Fold fstep finitial fextract)
2163− (Parser stepL initialL extractL)
2164− (Parser stepR initialR _) =
2161+ => Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
2162+manyTill (Parser stepL initialL extractL)
2163+ (Parser stepR initialR _)
2164+ (Fold fstep finitial fextract) =
21652165 Parser step initial extract
21662166
21672167 where