@@ -85,9 +85,9 @@ module Streamly.Internal.Data.Parser
8585 -- , take -- takeBetween 0 n
8686 , takeEQ -- takeBetween n n
8787 , takeGE -- takeBetween n maxBound
88+ , takeP
8889
8990 -- Grab a sequence of input elements by inspecting them
90− , takeP
9191 , lookAhead
9292 , takeWhileP
9393 , takeWhile
@@ -95,16 +95,22 @@ module Streamly.Internal.Data.Parser
9595 , takeWhile1
9696 , drainWhile
9797
98+ -- Separators
9899 , sliceSepByP
99100 , sliceBeginWith
100101 , sliceSepWith
102+
103+ -- Quoting and Escaping
101104 , escapedSliceSepBy
102105 , escapedFrameBy
106+
107+ -- Words and grouping
103108 , wordBy
104109 , groupBy
105110 , groupByRolling
106111 , groupByRollingEither
107112 , eqBy
113+
108114 -- | Unimplemented
109115 --
110116 -- @
@@ -498,6 +504,10 @@ takeEQ n = D.toParserK . D.takeEQ n
498504takeGE :: MonadCatch m => Int -> Fold m a b -> Parser m a b
499505takeGE n = D.toParserK . D.takeGE n
500506
507+-------------------------------------------------------------------------------
508+-- Take until a condition
509+-------------------------------------------------------------------------------
510+
501511-- $takeWhile
502512-- Note: This is called @takeWhileP@ and @munch@ in some parser libraries.
503513
@@ -562,6 +572,10 @@ takeWhile1 cond = D.toParserK . D.takeWhile1 cond
562572drainWhile :: MonadCatch m => (a -> Bool) -> Parser m a ()
563573drainWhile p = takeWhile p FL.drain
564574
575+-------------------------------------------------------------------------------
576+-- Separators
577+-------------------------------------------------------------------------------
578+
565579-- | @sliceSepByP cond parser@ parses a slice of the input using @parser@ until
566580-- @cond@ succeeds or the parser stops.
567581--
@@ -630,6 +644,10 @@ sliceBeginWith ::
630644 (a -> Bool) -> Fold m a b -> Parser m a b
631645sliceBeginWith cond = D.toParserK . D.sliceBeginWith cond
632646
647+-------------------------------------------------------------------------------
648+-- Quoting and Escaping
649+-------------------------------------------------------------------------------
650+
633651-- | Like 'sliceSepBy' but the separator elements can be escaped using an
634652-- escape char determined by the second predicate.
635653--
@@ -669,6 +687,10 @@ escapedFrameBy :: -- MonadCatch m =>
669687escapedFrameBy _begin _end _escape _p = undefined
670688 -- D.toParserK . D.frameBy begin end escape p
671689
690+-------------------------------------------------------------------------------
691+-- Grouping and words
692+-------------------------------------------------------------------------------
693+
672694-- | Like 'splitOn' but strips leading, trailing, and repeated separators.
673695-- Therefore, @".a..b."@ having '.' as the separator would be parsed as
674696-- @["a","b"]@. In other words, its like parsing words from whitespace