on master help sign in
Change ParserD.manyTill signature, move Fold at end (#1900)
f390e53Ranjeet Ranjan
benchmark/Streamly/Benchmark/Data/Parser/ParserD.hs+1−1
@@ -143,7 +143,7 @@ manyTill :: MonadThrow m => Int -> Stream m Int -> m Int
143manyTill value =
143manyTill value =
144 let p = PR.satisfy (> 0)
144 let p = PR.satisfy (> 0)
145 pcond = PR.satisfy (== value)
145 pcond = PR.satisfy (== value)
146− in Stream.parseD (PR.manyTill Fold.length p pcond)
146+ in Stream.parseD (PR.manyTill p pcond Fold.length)
147
147
148{-# INLINE serialWith #-}
148{-# INLINE serialWith #-}
149serialWith :: MonadThrow m
149serialWith :: MonadThrow m
core/src/Streamly/Internal/Data/Parser.hs+3−3
@@ -1384,7 +1384,7 @@ manyTillP :: -- Monad m =>
1384manyTillP _p1 _p2 _f = undefined
1384manyTillP _p1 _p2 _f = undefined
1385 -- D.toParserK $ D.manyTillP (D.fromParserK p1) (D.fromParserK p2) f
1385 -- D.toParserK $ D.manyTillP (D.fromParserK p1) (D.fromParserK p2) f
1386
1386
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@
1388-- fails it backtracks and tries @collect@, after @collect@ succeeds @test@ is
1388-- fails it backtracks and tries @collect@, after @collect@ succeeds @test@ is
1389-- tried again and so on. The parser stops when @test@ succeeds. The output of
1389-- tried again and so on. The parser stops when @test@ succeeds. The output of
1390-- @test@ is discarded and the output of @collect@ is accumulated by the
1390-- @test@ is discarded and the output of @collect@ is accumulated by the
@@ -1397,8 +1397,8 @@ manyTillP _p1 _p2 _f = undefined
1397{-# INLINE manyTill #-}
1397{-# INLINE manyTill #-}
1398manyTill :: Monad m
1398manyTill :: Monad m
1399 => Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
1399 => Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
1400−manyTill p1 p2 f =
1400+manyTill collect test f =
1401− D.toParserK $ D.manyTill f (D.fromParserK p1) (D.fromParserK p2)
1401+ D.toParserK $ D.manyTill (D.fromParserK collect) (D.fromParserK test) f
1402
1402
1403-- | @manyThen f collect recover@ repeats the parser @collect@ on the input and
1403-- | @manyThen f collect recover@ repeats the parser @collect@ on the input and
1404-- collects the output in the supplied fold. If the the parser @collect@ fails,
1404-- 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
2158--
2158--
2159{-# INLINE manyTill #-}
2159{-# INLINE manyTill #-}
2160manyTill :: Monad m
2160manyTill :: Monad m
2161− => Fold m b c -> Parser m a b -> Parser m a x -> Parser m a c
2161+ => Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
2162−manyTill (Fold fstep finitial fextract)
2163− (Parser stepL initialL extractL)
2162+manyTill (Parser stepL initialL extractL)
2164− (Parser stepR initialR _) =
2163+ (Parser stepR initialR _)
2164+ (Fold fstep finitial fextract) =
2165 Parser step initial extract
2165 Parser step initial extract
2166
2166
2167 where
2167 where