on master help sign in
Change Parser.sepBy signature, move Fold at end (#1905)
commitda36a011f183b942f701deff4c7c3cdf58d15349 authorRanjeet Ranjan <ranjeetr@composewell.com> dateFri 7 Oct 2022, 19:57 (4 years ago) parent666dbb0
3 files changed+7−7
benchmark/Streamly/Benchmark/Data/Parser.hs+1−1 core/src/Streamly/Internal/Data/Parser.hs+3−3 core/src/Streamly/Internal/Data/Parser/ParserD.hs+3−3
benchmark/Streamly/Benchmark/Data/Parser.hs+1−1
@@ -189,7 +189,7 @@ wordBy value = Stream.parse (PR.wordBy (>= value) Fold.drain)
189189sepByWords :: MonadThrow m => Int -> Stream m Int -> m ()
190190sepByWords _ = Stream.parse (wrds even Fold.drain)
191191 where
192− wrds p f = PR.sepBy f (PR.takeWhile (not . p) Fold.drain) (PR.dropWhile p)
192+ wrds p = PR.sepBy (PR.takeWhile (not . p) Fold.drain) (PR.dropWhile p)
193193
194194{-# INLINE deintercalate #-}
195195deintercalate :: MonadThrow m => Int -> Stream m Int -> m ()
core/src/Streamly/Internal/Data/Parser.hs+3−3
@@ -1479,9 +1479,9 @@ sepBy1 sink p sep = do
14791479--
14801480{-# INLINE sepBy #-}
14811481sepBy :: Monad m =>
1482− Fold m b c -> Parser m a b -> Parser m a x -> Parser m a c
1483−sepBy sink content sep =
1484− D.toParserK $ D.sepBy sink (D.fromParserK content) (D.fromParserK sep)
1482+ Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
1483+sepBy content sep sink =
1484+ D.toParserK $ D.sepBy (D.fromParserK content) (D.fromParserK sep) sink
14851485-- sepBy sink = deintercalate (FL.lefts sink)
14861486
14871487-------------------------------------------------------------------------------
core/src/Streamly/Internal/Data/Parser/ParserD.hs+3−3
@@ -1932,11 +1932,11 @@ data SepByState fs sp ss =
19321932-- terms of deintercalate.
19331933{-# INLINE sepBy #-}
19341934sepBy :: Monad m =>
1935− Fold m b c -> Parser m a b -> Parser m a x -> Parser m a c
1935+ Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
19361936sepBy
1937− (Fold fstep finitial fextract)
19381937 (Parser pstep pinitial pextract)
1939− (Parser sstep sinitial _) = Parser step initial extract
1938+ (Parser sstep sinitial _)
1939+ (Fold fstep finitial fextract) = Parser step initial extract
19401940
19411941 where
19421942