on master help sign in
Change Parser.sepBy signature, move Fold at end (#1905)
da36a01Ranjeet Ranjan
benchmark/Streamly/Benchmark/Data/Parser.hs+1−1
@@ -189,7 +189,7 @@ wordBy value = Stream.parse (PR.wordBy (>= value) Fold.drain)
189sepByWords :: MonadThrow m => Int -> Stream m Int -> m ()
189sepByWords :: MonadThrow m => Int -> Stream m Int -> m ()
190sepByWords _ = Stream.parse (wrds even Fold.drain)
190sepByWords _ = Stream.parse (wrds even Fold.drain)
191 where
191 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)
193
193
194{-# INLINE deintercalate #-}
194{-# INLINE deintercalate #-}
195deintercalate :: MonadThrow m => Int -> Stream m Int -> m ()
195deintercalate :: 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
1479--
1479--
1480{-# INLINE sepBy #-}
1480{-# INLINE sepBy #-}
1481sepBy :: Monad m =>
1481sepBy :: Monad m =>
1482− Fold m b c -> Parser m a b -> Parser m a x -> Parser m a c
1482+ Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
1483−sepBy sink content sep =
1483+sepBy content sep sink =
1484− D.toParserK $ D.sepBy sink (D.fromParserK content) (D.fromParserK sep)
1484+ D.toParserK $ D.sepBy (D.fromParserK content) (D.fromParserK sep) sink
1485-- sepBy sink = deintercalate (FL.lefts sink)
1485-- sepBy sink = deintercalate (FL.lefts sink)
1486
1486
1487-------------------------------------------------------------------------------
1487-------------------------------------------------------------------------------
core/src/Streamly/Internal/Data/Parser/ParserD.hs+3−3
@@ -1932,11 +1932,11 @@ data SepByState fs sp ss =
1932-- terms of deintercalate.
1932-- terms of deintercalate.
1933{-# INLINE sepBy #-}
1933{-# INLINE sepBy #-}
1934sepBy :: Monad m =>
1934sepBy :: 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
1936sepBy
1936sepBy
1937− (Fold fstep finitial fextract)
1938 (Parser pstep pinitial pextract)
1937 (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
1940
1940
1941 where
1941 where
1942
1942