on master help sign in
Change the signature of Parser.deintercalate, move fold at end (#1904)
61eb3f4Ranjeet Ranjan
benchmark/Streamly/Benchmark/Data/Parser.hs+1−1
@@ -199,7 +199,7 @@ deintercalate _ = Stream.parse (partition even)
199
199
200 partition p =
200 partition p =
201 PR.deintercalate
201 PR.deintercalate
202− Fold.drain (PR.takeWhile (not . p) Fold.sum) (PR.takeWhile p Fold.sum)
202+ (PR.takeWhile (not . p) Fold.sum) (PR.takeWhile p Fold.sum) Fold.drain
203
203
204{-# INLINE manyWordByEven #-}
204{-# INLINE manyWordByEven #-}
205manyWordByEven :: MonadThrow m => Stream m Int -> m ()
205manyWordByEven :: MonadThrow m => Stream m Int -> m ()
core/src/Streamly/Internal/Data/Parser.hs+5−5
@@ -1446,14 +1446,14 @@ manyThen _parser _recover _f = undefined
1446--
1446--
1447{-# INLINE deintercalate #-}
1447{-# INLINE deintercalate #-}
1448deintercalate :: Monad m =>
1448deintercalate :: Monad m =>
1449− Fold m (Either x y) z
1450− -> Parser m a x
1449+ Parser m a x
1451 -> Parser m a y
1450 -> Parser m a y
1451+ -> Fold m (Either x y) z
1452 -> Parser m a z
1452 -> Parser m a z
1453−deintercalate sink contentL contentR =
1453+deintercalate contentL contentR sink =
1454 D.toParserK
1454 D.toParserK
1455 $ D.deintercalate
1455 $ D.deintercalate
1456− sink (D.fromParserK contentL) (D.fromParserK contentR)
1456+ (D.fromParserK contentL) (D.fromParserK contentR) sink
1457
1457
1458-- | Parse items separated by a separator parsed by the supplied parser. At
1458-- | Parse items separated by a separator parsed by the supplied parser. At
1459-- least one item must be present for the parser to succeed.
1459-- least one item must be present for the parser to succeed.
@@ -1474,7 +1474,7 @@ sepBy1 sink p sep = do
1474-- run, when it is done content parser is run again and so on. If none of the
1474-- run, when it is done content parser is run again and so on. If none of the
1475-- parsers consumes an input then parser returns a failure.
1475-- parsers consumes an input then parser returns a failure.
1476--
1476--
1477−-- >>> sepBy sink = Parser.deintercalate (Fold.lefts sink)
1477+-- >>> sepBy sink p1 p2 = Parser.deintercalate p1 p2 (Fold.lefts sink)
1478-- >>> sepBy sink content sep = Parser.sepBy1 sink content sep <|> return mempty
1478-- >>> sepBy sink content sep = Parser.sepBy1 sink content sep <|> return mempty
1479--
1479--
1480{-# INLINE sepBy #-}
1480{-# INLINE sepBy #-}
core/src/Streamly/Internal/Data/Parser/ParserD.hs+4−4
@@ -1835,14 +1835,14 @@ data DeintercalateState fs sp ss =
1835--
1835--
1836{-# INLINE deintercalate #-}
1836{-# INLINE deintercalate #-}
1837deintercalate :: Monad m =>
1837deintercalate :: Monad m =>
1838− Fold m (Either x y) z
1839− -> Parser m a x
1838+ Parser m a x
1840 -> Parser m a y
1839 -> Parser m a y
1840+ -> Fold m (Either x y) z
1841 -> Parser m a z
1841 -> Parser m a z
1842deintercalate
1842deintercalate
1843− (Fold fstep finitial fextract)
1844 (Parser stepL initialL extractL)
1843 (Parser stepL initialL extractL)
1845− (Parser stepR initialR extractR) = Parser step initial extract
1844+ (Parser stepR initialR extractR)
1845+ (Fold fstep finitial fextract) = Parser step initial extract
1846
1846
1847 where
1847 where
1848
1848
test/Streamly/Test/Data/Parser.hs+1−1
@@ -605,7 +605,7 @@ deintercalate =
605 partition =
605 partition =
606 FL.tee (fmap concat $ FL.lefts FL.toList)
606 FL.tee (fmap concat $ FL.lefts FL.toList)
607 (fmap concat $ FL.rights FL.toList)
607 (fmap concat $ FL.rights FL.toList)
608− p = P.deintercalate partition p1 p2
608+ p = P.deintercalate p1 p2 partition
609
609
610-- shortestPass :: Property
610-- shortestPass :: Property
611-- shortestPass =
611-- shortestPass =