@@ -237,7 +237,7 @@ import qualified Streamly.Internal.Data.Parser.ParserK.Type as K
238{-# INLINE toFold #-}
238{-# INLINE toFold #-}
239toFold :: MonadThrow m => Parser m a b -> Fold m a b
239toFold :: MonadThrow m => Parser m a b -> Fold m a b
240−toFold p = D.toFold $ K.fromParserK p
240+toFold p = D.toFold $ D.fromParserK p
242-------------------------------------------------------------------------------
242-------------------------------------------------------------------------------
243-- Upgrade folds to parses
243-- Upgrade folds to parses
@@ -249,7 +249,7 @@ toFold p = D.toFold $ K.fromParserK p
250{-# INLINE fromFold #-}
250{-# INLINE fromFold #-}
251fromFold :: MonadCatch m => Fold m a b -> Parser m a b
251fromFold :: MonadCatch m => Fold m a b -> Parser m a b
252−fromFold = K.toParserK . D.fromFold
252+fromFold = D.toParserK . D.fromFold
254-------------------------------------------------------------------------------
254-------------------------------------------------------------------------------
255-- Terminating but not failing folds
255-- Terminating but not failing folds
@@ -263,9 +263,9 @@ fromFold = K.toParserK . D.fromFold
264{-# INLINE [3] fromPure #-}
264{-# INLINE [3] fromPure #-}
265fromPure :: MonadCatch m => b -> Parser m a b
265fromPure :: MonadCatch m => b -> Parser m a b
266−fromPure = K.toParserK . D.fromPure
266+fromPure = D.toParserK . D.fromPure
267{-# RULES "fromPure fallback to CPS" [2]
267{-# RULES "fromPure fallback to CPS" [2]
268− forall a. K.toParserK (D.fromPure a) = K.fromPure a #-}
268+ forall a. D.toParserK (D.fromPure a) = K.fromPure a #-}
270-- This is the dual of stream "fromEffect".
270-- This is the dual of stream "fromEffect".
@@ -276,7 +276,7 @@ fromPure = K.toParserK . D.fromPure
277{-# INLINE fromEffect #-}
277{-# INLINE fromEffect #-}
278fromEffect :: MonadCatch m => m b -> Parser m a b
278fromEffect :: MonadCatch m => m b -> Parser m a b
279−fromEffect = K.fromEffect -- K.toParserK . D.fromEffect
279+fromEffect = K.fromEffect -- D.toParserK . D.fromEffect
281-- This is the dual of "nil".
281-- This is the dual of "nil".
@@ -287,9 +287,9 @@ fromEffect = K.fromEffect -- K.toParserK . D.fromEffect
288{-# INLINE [3] die #-}
288{-# INLINE [3] die #-}
289die :: MonadCatch m => String -> Parser m a b
289die :: MonadCatch m => String -> Parser m a b
290−die = K.toParserK . D.die
290+die = D.toParserK . D.die
291{-# RULES "die fallback to CPS" [2]
291{-# RULES "die fallback to CPS" [2]
292− forall a. K.toParserK (D.die a) = K.die a #-}
292+ forall a. D.toParserK (D.die a) = K.die a #-}
294-- This is the dual of "nilM".
294-- This is the dual of "nilM".
@@ -300,7 +300,7 @@ die = K.toParserK . D.die
301{-# INLINE dieM #-}
301{-# INLINE dieM #-}
302dieM :: MonadCatch m => m String -> Parser m a b
302dieM :: MonadCatch m => m String -> Parser m a b
303−dieM = K.toParserK . D.dieM
303+dieM = D.toParserK . D.dieM
305-------------------------------------------------------------------------------
305-------------------------------------------------------------------------------
306-- Failing Parsers
306-- Failing Parsers
@@ -320,7 +320,7 @@ dieM = K.toParserK . D.dieM
321{-# INLINE peek #-}
321{-# INLINE peek #-}
322peek :: MonadCatch m => Parser m a a
322peek :: MonadCatch m => Parser m a a
323−peek = K.toParserK D.peek
323+peek = D.toParserK D.peek
325-- | Succeeds if we are at the end of input, fails otherwise.
325-- | Succeeds if we are at the end of input, fails otherwise.
@@ -331,7 +331,7 @@ peek = K.toParserK D.peek
332{-# INLINE eof #-}
332{-# INLINE eof #-}
333eof :: MonadCatch m => Parser m a ()
333eof :: MonadCatch m => Parser m a ()
334−eof = K.toParserK D.eof
334+eof = D.toParserK D.eof
336-- | Returns the next element if it passes the predicate, fails otherwise.
336-- | Returns the next element if it passes the predicate, fails otherwise.
@@ -342,7 +342,7 @@ eof = K.toParserK D.eof
343{-# INLINE satisfy #-}
343{-# INLINE satisfy #-}
344satisfy :: MonadCatch m => (a -> Bool) -> Parser m a a
344satisfy :: MonadCatch m => (a -> Bool) -> Parser m a a
345−satisfy = K.toParserK . D.satisfy
345+satisfy = D.toParserK . D.satisfy
347-- | Return the next element of the input. Returns 'Nothing'
347-- | Return the next element of the input. Returns 'Nothing'
348-- on end of input. Also known as 'head'.
348-- on end of input. Also known as 'head'.
@@ -351,7 +351,7 @@ satisfy = K.toParserK . D.satisfy
352{-# INLINE next #-}
352{-# INLINE next #-}
353next :: MonadCatch m => Parser m a (Maybe a)
353next :: MonadCatch m => Parser m a (Maybe a)
354−next = K.toParserK D.next
354+next = D.toParserK D.next
356-- | Map a 'Maybe' returning function on the next element in the stream. The
356-- | Map a 'Maybe' returning function on the next element in the stream. The
357-- parser fails if the function returns 'Nothing' otherwise returns the 'Just'
357-- parser fails if the function returns 'Nothing' otherwise returns the 'Just'
@@ -361,7 +361,7 @@ next = K.toParserK D.next
362{-# INLINE maybe #-}
362{-# INLINE maybe #-}
363maybe :: MonadCatch m => (a -> Maybe b) -> Parser m a b
363maybe :: MonadCatch m => (a -> Maybe b) -> Parser m a b
364−maybe = K.toParserK . D.maybe
364+maybe = D.toParserK . D.maybe
366-- | Map an 'Either' returning function on the next element in the stream. If
366-- | Map an 'Either' returning function on the next element in the stream. If
367-- the function returns 'Left err', the parser fails with the error message
367-- the function returns 'Left err', the parser fails with the error message
@@ -371,7 +371,7 @@ maybe = K.toParserK . D.maybe
372{-# INLINE either #-}
372{-# INLINE either #-}
373either :: MonadCatch m => (a -> Either String b) -> Parser m a b
373either :: MonadCatch m => (a -> Either String b) -> Parser m a b
374−either = K.toParserK . D.either
374+either = D.toParserK . D.either
376-------------------------------------------------------------------------------
376-------------------------------------------------------------------------------
377-- Taking elements
377-- Taking elements
@@ -423,7 +423,7 @@ either = K.toParserK . D.either
423{-# INLINE takeBetween #-}
423{-# INLINE takeBetween #-}
424takeBetween :: MonadCatch m =>
424takeBetween :: MonadCatch m =>
425 Int -> Int -> Fold m a b -> Parser m a b
425 Int -> Int -> Fold m a b -> Parser m a b
426−takeBetween m n = K.toParserK . D.takeBetween m n
426+takeBetween m n = D.toParserK . D.takeBetween m n
428-- | Stops after taking exactly @n@ input elements.
428-- | Stops after taking exactly @n@ input elements.
@@ -438,7 +438,7 @@ takeBetween m n = K.toParserK . D.takeBetween m n
439{-# INLINE takeEQ #-}
439{-# INLINE takeEQ #-}
440takeEQ :: MonadCatch m => Int -> Fold m a b -> Parser m a b
440takeEQ :: MonadCatch m => Int -> Fold m a b -> Parser m a b
441−takeEQ n = K.toParserK . D.takeEQ n
441+takeEQ n = D.toParserK . D.takeEQ n
443-- | Take at least @n@ input elements, but can collect more.
443-- | Take at least @n@ input elements, but can collect more.
@@ -456,7 +456,7 @@ takeEQ n = K.toParserK . D.takeEQ n
457{-# INLINE takeGE #-}
457{-# INLINE takeGE #-}
458takeGE :: MonadCatch m => Int -> Fold m a b -> Parser m a b
458takeGE :: MonadCatch m => Int -> Fold m a b -> Parser m a b
459−takeGE n = K.toParserK . D.takeGE n
459+takeGE n = D.toParserK . D.takeGE n
461-- $takeWhile
461-- $takeWhile
462-- Note: This is called @takeWhileP@ and @munch@ in some parser libraries.
462-- Note: This is called @takeWhileP@ and @munch@ in some parser libraries.
@@ -480,7 +480,7 @@ takeGE n = K.toParserK . D.takeGE n
480{-# INLINE takeWhileP #-}
480{-# INLINE takeWhileP #-}
481takeWhileP :: -- MonadCatch m =>
481takeWhileP :: -- MonadCatch m =>
482 (a -> Bool) -> Parser m a b -> Parser m a b
482 (a -> Bool) -> Parser m a b -> Parser m a b
483−takeWhileP _cond = undefined -- K.toParserK . D.takeWhileP cond
483+takeWhileP _cond = undefined -- D.toParserK . D.takeWhileP cond
485-- | Collect stream elements until an element fails the predicate. The element
485-- | Collect stream elements until an element fails the predicate. The element
486-- on which the predicate fails is returned back to the input stream.
486-- on which the predicate fails is returned back to the input stream.
@@ -501,7 +501,7 @@ takeWhileP _cond = undefined -- K.toParserK . D.takeWhileP cond
502{-# INLINE takeWhile #-}
502{-# INLINE takeWhile #-}
503takeWhile :: MonadCatch m => (a -> Bool) -> Fold m a b -> Parser m a b
503takeWhile :: MonadCatch m => (a -> Bool) -> Fold m a b -> Parser m a b
504−takeWhile cond = K.toParserK . D.takeWhile cond
504+takeWhile cond = D.toParserK . D.takeWhile cond
506-- | Like 'takeWhile' but takes at least one element otherwise fails.
506-- | Like 'takeWhile' but takes at least one element otherwise fails.
@@ -509,7 +509,7 @@ takeWhile cond = K.toParserK . D.takeWhile cond
510{-# INLINE takeWhile1 #-}
510{-# INLINE takeWhile1 #-}
511takeWhile1 :: MonadCatch m => (a -> Bool) -> Fold m a b -> Parser m a b
511takeWhile1 :: MonadCatch m => (a -> Bool) -> Fold m a b -> Parser m a b
512−takeWhile1 cond = K.toParserK . D.takeWhile1 cond
512+takeWhile1 cond = D.toParserK . D.takeWhile1 cond
514-- | Drain the input as long as the predicate succeeds, running the effects and
514-- | Drain the input as long as the predicate succeeds, running the effects and
515-- discarding the results.
515-- discarding the results.
@@ -539,7 +539,7 @@ drainWhile p = takeWhile p FL.drain
539sliceSepByP ::
539sliceSepByP ::
540 MonadCatch m =>
540 MonadCatch m =>
541 (a -> Bool) -> Parser m a b -> Parser m a b
541 (a -> Bool) -> Parser m a b -> Parser m a b
542−sliceSepByP cond = K.toParserK . D.sliceSepByP cond . K.fromParserK
542+sliceSepByP cond = D.toParserK . D.sliceSepByP cond . D.fromParserK
544-- | Like 'sliceSepBy' but does not drop the separator element, instead
544-- | Like 'sliceSepBy' but does not drop the separator element, instead
545-- separator is emitted as a separate element in the output.
545-- separator is emitted as a separate element in the output.
@@ -548,7 +548,7 @@ sliceSepByP cond = K.toParserK . D.sliceSepByP cond . K.fromParserK
548{-# INLINE sliceSepWith #-}
548{-# INLINE sliceSepWith #-}
549sliceSepWith :: -- MonadCatch m =>
549sliceSepWith :: -- MonadCatch m =>
550 (a -> Bool) -> Fold m a b -> Parser m a b
550 (a -> Bool) -> Fold m a b -> Parser m a b
551−sliceSepWith _cond = undefined -- K.toParserK . D.sliceSepBy cond
551+sliceSepWith _cond = undefined -- D.toParserK . D.sliceSepBy cond
553-- | Collect stream elements until an elements passes the predicate, return the
553-- | Collect stream elements until an elements passes the predicate, return the
554-- last element on which the predicate succeeded back to the input stream. If
554-- last element on which the predicate succeeded back to the input stream. If
@@ -588,7 +588,7 @@ sliceSepWith _cond = undefined -- K.toParserK . D.sliceSepBy cond
588sliceBeginWith ::
588sliceBeginWith ::
589 MonadCatch m =>
589 MonadCatch m =>
590 (a -> Bool) -> Fold m a b -> Parser m a b
590 (a -> Bool) -> Fold m a b -> Parser m a b
591−sliceBeginWith cond = K.toParserK . D.sliceBeginWith cond
591+sliceBeginWith cond = D.toParserK . D.sliceBeginWith cond
593-- | Like 'sliceSepBy' but the separator elements can be escaped using an
593-- | Like 'sliceSepBy' but the separator elements can be escaped using an
594-- escape char determined by the second predicate.
594-- escape char determined by the second predicate.
@@ -598,7 +598,7 @@ sliceBeginWith cond = K.toParserK . D.sliceBeginWith cond
598escapedSliceSepBy :: -- MonadCatch m =>
598escapedSliceSepBy :: -- MonadCatch m =>
599 (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser m a b
599 (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser m a b
600escapedSliceSepBy _cond _esc = undefined
600escapedSliceSepBy _cond _esc = undefined
601− -- K.toParserK . D.escapedSliceSepBy cond esc
601+ -- D.toParserK . D.escapedSliceSepBy cond esc
603-- | @escapedFrameBy begin end escape@ parses a string framed using @begin@ and
603-- | @escapedFrameBy begin end escape@ parses a string framed using @begin@ and
604-- @end@ as the frame begin and end marker elements and @escape@ as an escaping
604-- @end@ as the frame begin and end marker elements and @escape@ as an escaping
@@ -627,7 +627,7 @@ escapedSliceSepBy _cond _esc = undefined
627escapedFrameBy :: -- MonadCatch m =>
627escapedFrameBy :: -- MonadCatch m =>
628 (a -> Bool) -> (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser m a b
628 (a -> Bool) -> (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser m a b
629escapedFrameBy _begin _end _escape _p = undefined
629escapedFrameBy _begin _end _escape _p = undefined
630− -- K.toParserK . D.frameBy begin end escape p
630+ -- D.toParserK . D.frameBy begin end escape p
632-- | Like 'splitOn' but strips leading, trailing, and repeated separators.
632-- | Like 'splitOn' but strips leading, trailing, and repeated separators.
633-- Therefore, @".a..b."@ having '.' as the separator would be parsed as
633-- Therefore, @".a..b."@ having '.' as the separator would be parsed as
@@ -643,7 +643,7 @@ escapedFrameBy _begin _end _escape _p = undefined
644{-# INLINE wordBy #-}
644{-# INLINE wordBy #-}
645wordBy :: MonadCatch m => (a -> Bool) -> Fold m a b -> Parser m a b
645wordBy :: MonadCatch m => (a -> Bool) -> Fold m a b -> Parser m a b
646−wordBy f = K.toParserK . D.wordBy f
646+wordBy f = D.toParserK . D.wordBy f
648-- | Given an input stream @[a,b,c,...]@ and a comparison function @cmp@, the
648-- | Given an input stream @[a,b,c,...]@ and a comparison function @cmp@, the
649-- parser assigns the element @a@ to the first group, then if @a \`cmp` b@ is
649-- parser assigns the element @a@ to the first group, then if @a \`cmp` b@ is
@@ -675,7 +675,7 @@ wordBy f = K.toParserK . D.wordBy f
676{-# INLINE groupBy #-}
676{-# INLINE groupBy #-}
677groupBy :: MonadCatch m => (a -> a -> Bool) -> Fold m a b -> Parser m a b
677groupBy :: MonadCatch m => (a -> a -> Bool) -> Fold m a b -> Parser m a b
678−groupBy eq = K.toParserK . D.groupBy eq
678+groupBy eq = D.toParserK . D.groupBy eq
680-- | Unlike 'groupBy' this combinator performs a rolling comparison of two
680-- | Unlike 'groupBy' this combinator performs a rolling comparison of two
681-- successive elements in the input stream. Assuming the input stream to the
681-- successive elements in the input stream. Assuming the input stream to the
@@ -709,7 +709,7 @@ groupBy eq = K.toParserK . D.groupBy eq
710{-# INLINE groupByRolling #-}
710{-# INLINE groupByRolling #-}
711groupByRolling :: MonadCatch m => (a -> a -> Bool) -> Fold m a b -> Parser m a b
711groupByRolling :: MonadCatch m => (a -> a -> Bool) -> Fold m a b -> Parser m a b
712−groupByRolling eq = K.toParserK . D.groupByRolling eq
712+groupByRolling eq = D.toParserK . D.groupByRolling eq
714-- | Like 'groupByRolling', but if the predicate is 'True' then collects using
714-- | Like 'groupByRolling', but if the predicate is 'True' then collects using
715-- the first fold as long as the predicate holds 'True', if the predicate is
715-- the first fold as long as the predicate holds 'True', if the predicate is
@@ -724,7 +724,7 @@ groupByRolling eq = K.toParserK . D.groupByRolling eq
724{-# INLINE groupByRollingEither #-}
724{-# INLINE groupByRollingEither #-}
725groupByRollingEither :: MonadCatch m =>
725groupByRollingEither :: MonadCatch m =>
726 (a -> a -> Bool) -> Fold m a b -> Fold m a c -> Parser m a (Either b c)
726 (a -> a -> Bool) -> Fold m a b -> Fold m a c -> Parser m a (Either b c)
727−groupByRollingEither eq f1 = K.toParserK . D.groupByRollingEither eq f1
727+groupByRollingEither eq f1 = D.toParserK . D.groupByRollingEither eq f1
729-- | Match the given sequence of elements using the given comparison function.
729-- | Match the given sequence of elements using the given comparison function.
@@ -737,7 +737,7 @@ groupByRollingEither eq f1 = K.toParserK . D.groupByRollingEither eq f1
738{-# INLINE eqBy #-}
738{-# INLINE eqBy #-}
739eqBy :: MonadCatch m => (a -> a -> Bool) -> [a] -> Parser m a ()
739eqBy :: MonadCatch m => (a -> a -> Bool) -> [a] -> Parser m a ()
740−eqBy cmp = K.toParserK . D.eqBy cmp
740+eqBy cmp = D.toParserK . D.eqBy cmp
742-------------------------------------------------------------------------------
742-------------------------------------------------------------------------------
743-- nested parsers
743-- nested parsers
@@ -789,7 +789,7 @@ eqBy cmp = K.toParserK . D.eqBy cmp
789serialWith :: MonadCatch m
789serialWith :: MonadCatch m
790 => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
790 => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
791serialWith f p1 p2 =
791serialWith f p1 p2 =
792− K.toParserK $ D.serialWith f (K.fromParserK p1) (K.fromParserK p2)
792+ D.toParserK $ D.serialWith f (D.fromParserK p1) (D.fromParserK p2)
794-- | Sequential parser application ignoring the output of the first parser.
794-- | Sequential parser application ignoring the output of the first parser.
795-- Apply two parsers sequentially to an input stream. The input is provided to
795-- Apply two parsers sequentially to an input stream. The input is provided to
@@ -813,7 +813,7 @@ serialWith f p1 p2 =
814{-# INLINE split_ #-}
814{-# INLINE split_ #-}
815split_ :: MonadCatch m => Parser m x a -> Parser m x b -> Parser m x b
815split_ :: MonadCatch m => Parser m x a -> Parser m x b -> Parser m x b
816−split_ p1 p2 = K.toParserK $ D.split_ (K.fromParserK p1) (K.fromParserK p2)
816+split_ p1 p2 = D.toParserK $ D.split_ (D.fromParserK p1) (D.fromParserK p2)
818-- | @teeWith f p1 p2@ distributes its input to both @p1@ and @p2@ until both
818-- | @teeWith f p1 p2@ distributes its input to both @p1@ and @p2@ until both
819-- of them succeed or anyone of them fails and combines their output using @f@.
819-- of them succeed or anyone of them fails and combines their output using @f@.
@@ -825,7 +825,7 @@ split_ p1 p2 = K.toParserK $ D.split_ (K.fromParserK p1) (K.fromParserK p2)
825teeWith :: MonadCatch m
825teeWith :: MonadCatch m
826 => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
826 => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
827teeWith f p1 p2 =
827teeWith f p1 p2 =
828− K.toParserK $ D.teeWith f (K.fromParserK p1) (K.fromParserK p2)
828+ D.toParserK $ D.teeWith f (D.fromParserK p1) (D.fromParserK p2)
830-- | Like 'teeWith' but ends parsing and zips the results, if available,
830-- | Like 'teeWith' but ends parsing and zips the results, if available,
831-- whenever the first parser ends.
831-- whenever the first parser ends.
@@ -836,7 +836,7 @@ teeWith f p1 p2 =
836teeWithFst :: MonadCatch m
836teeWithFst :: MonadCatch m
837 => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
837 => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
838teeWithFst f p1 p2 =
838teeWithFst f p1 p2 =
839− K.toParserK $ D.teeWithFst f (K.fromParserK p1) (K.fromParserK p2)
839+ D.toParserK $ D.teeWithFst f (D.fromParserK p1) (D.fromParserK p2)
841-- | Like 'teeWith' but ends parsing and zips the results, if available,
841-- | Like 'teeWith' but ends parsing and zips the results, if available,
842-- whenever any of the parsers ends or fails.
842-- whenever any of the parsers ends or fails.
@@ -847,7 +847,7 @@ teeWithFst f p1 p2 =
847teeWithMin :: MonadCatch m
847teeWithMin :: MonadCatch m
848 => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
848 => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
849teeWithMin f p1 p2 =
849teeWithMin f p1 p2 =
850− K.toParserK $ D.teeWithMin f (K.fromParserK p1) (K.fromParserK p2)
850+ D.toParserK $ D.teeWithMin f (D.fromParserK p1) (D.fromParserK p2)
852-- | Sequential alternative. Apply the input to the first parser and return the
852-- | Sequential alternative. Apply the input to the first parser and return the
853-- result if the parser succeeds. If the first parser fails then backtrack and
853-- result if the parser succeeds. If the first parser fails then backtrack and
@@ -868,7 +868,7 @@ teeWithMin f p1 p2 =
869{-# INLINE alt #-}
869{-# INLINE alt #-}
870alt :: MonadCatch m => Parser m x a -> Parser m x a -> Parser m x a
870alt :: MonadCatch m => Parser m x a -> Parser m x a -> Parser m x a
871−alt p1 p2 = K.toParserK $ D.alt (K.fromParserK p1) (K.fromParserK p2)
871+alt p1 p2 = D.toParserK $ D.alt (D.fromParserK p1) (D.fromParserK p2)
873-- | Shortest alternative. Apply both parsers in parallel but choose the result
873-- | Shortest alternative. Apply both parsers in parallel but choose the result
874-- from the one which consumed least input i.e. take the shortest succeeding
874-- from the one which consumed least input i.e. take the shortest succeeding
@@ -879,7 +879,7 @@ alt p1 p2 = K.toParserK $ D.alt (K.fromParserK p1) (K.fromParserK p2)
879{-# INLINE shortest #-}
879{-# INLINE shortest #-}
880shortest :: MonadCatch m
880shortest :: MonadCatch m
881 => Parser m x a -> Parser m x a -> Parser m x a
881 => Parser m x a -> Parser m x a -> Parser m x a
882−shortest p1 p2 = K.toParserK $ D.shortest (K.fromParserK p1) (K.fromParserK p2)
882+shortest p1 p2 = D.toParserK $ D.shortest (D.fromParserK p1) (D.fromParserK p2)
884-- | Longest alternative. Apply both parsers in parallel but choose the result
884-- | Longest alternative. Apply both parsers in parallel but choose the result
885-- from the one which consumed more input i.e. take the longest succeeding
885-- from the one which consumed more input i.e. take the longest succeeding
@@ -890,7 +890,7 @@ shortest p1 p2 = K.toParserK $ D.shortest (K.fromParserK p1) (K.fromParserK p2)
890{-# INLINE longest #-}
890{-# INLINE longest #-}
891longest :: MonadCatch m
891longest :: MonadCatch m
892 => Parser m x a -> Parser m x a -> Parser m x a
892 => Parser m x a -> Parser m x a -> Parser m x a
893−longest p1 p2 = K.toParserK $ D.longest (K.fromParserK p1) (K.fromParserK p2)
893+longest p1 p2 = D.toParserK $ D.longest (D.fromParserK p1) (D.fromParserK p2)
895-- | Run a parser without consuming the input.
895-- | Run a parser without consuming the input.
@@ -898,7 +898,7 @@ longest p1 p2 = K.toParserK $ D.longest (K.fromParserK p1) (K.fromParserK p2)
899{-# INLINE lookAhead #-}
899{-# INLINE lookAhead #-}
900lookAhead :: MonadCatch m => Parser m a b -> Parser m a b
900lookAhead :: MonadCatch m => Parser m a b -> Parser m a b
901−lookAhead p = K.toParserK $ D.lookAhead $ K.fromParserK p
901+lookAhead p = D.toParserK $ D.lookAhead $ D.fromParserK p
903-- | Takes at-most @n@ input elements.
903-- | Takes at-most @n@ input elements.
@@ -914,7 +914,7 @@ lookAhead p = K.toParserK $ D.lookAhead $ K.fromParserK p
914-- /Internal/
914-- /Internal/
915{-# INLINE takeP #-}
915{-# INLINE takeP #-}
916takeP :: MonadCatch m => Int -> Parser m a b -> Parser m a b
916takeP :: MonadCatch m => Int -> Parser m a b -> Parser m a b
917−takeP i p = K.toParserK $ D.takeP i $ K.fromParserK p
917+takeP i p = D.toParserK $ D.takeP i $ D.fromParserK p
919-------------------------------------------------------------------------------
919-------------------------------------------------------------------------------
920-- Interleaving
920-- Interleaving
@@ -982,7 +982,7 @@ concatSequence _f _p = undefined
982{-# INLINE concatMap #-}
982{-# INLINE concatMap #-}
983concatMap :: MonadCatch m
983concatMap :: MonadCatch m
984 => (b -> Parser m a c) -> Parser m a b -> Parser m a c
984 => (b -> Parser m a c) -> Parser m a b -> Parser m a c
985−concatMap f p = K.toParserK $ D.concatMap (K.fromParserK . f) (K.fromParserK p)
985+concatMap f p = D.toParserK $ D.concatMap (D.fromParserK . f) (D.fromParserK p)
987-------------------------------------------------------------------------------
987-------------------------------------------------------------------------------
988-- Alternative Collection
988-- Alternative Collection
@@ -998,7 +998,7 @@ concatMap f p = K.toParserK $ D.concatMap (K.fromParserK . f) (K.fromParserK p)
998{-# INLINE choice #-}
998{-# INLINE choice #-}
1000 (Functor t, Foldable t, MonadCatch m) => t (Parser m a b) -> Parser m a b
1000 (Functor t, Foldable t, MonadCatch m) => t (Parser m a b) -> Parser m a b
1001−choice ps = K.toParserK $ D.choice $ K.fromParserK <$> ps
1001+choice ps = D.toParserK $ D.choice $ D.fromParserK <$> ps
1003-------------------------------------------------------------------------------
1003-------------------------------------------------------------------------------
1004-- Sequential Repetition
1004-- Sequential Repetition
@@ -1017,7 +1017,7 @@ choice ps = K.toParserK $ D.choice $ K.fromParserK <$> ps
1017{-# INLINE manyP #-}
1017{-# INLINE manyP #-}
1018manyP :: -- MonadCatch m =>
1018manyP :: -- MonadCatch m =>
1019 Parser m a b -> Parser m b c -> Parser m a c
1019 Parser m a b -> Parser m b c -> Parser m a c
1020−manyP _p _f = undefined -- K.toParserK $ D.manyP (K.fromParserK p) f
1020+manyP _p _f = undefined -- D.toParserK $ D.manyP (D.fromParserK p) f
1022-- | Collect zero or more parses. Apply the supplied parser repeatedly on the
1022-- | Collect zero or more parses. Apply the supplied parser repeatedly on the
1023-- input stream and push the parse results to a downstream fold.
1023-- input stream and push the parse results to a downstream fold.
@@ -1031,7 +1031,7 @@ manyP _p _f = undefined -- K.toParserK $ D.manyP (K.fromParserK p) f
1032{-# INLINE many #-}
1032{-# INLINE many #-}
1033many :: MonadCatch m => Parser m a b -> Fold m b c -> Parser m a c
1033many :: MonadCatch m => Parser m a b -> Fold m b c -> Parser m a c
1034−many p f = K.toParserK $ D.many (K.fromParserK p) f
1034+many p f = D.toParserK $ D.many (D.fromParserK p) f
1035-- many = countBetween 0 maxBound
1035-- many = countBetween 0 maxBound
1037-- Note: many1 would perhaps be a better name for this and consistent with
1037-- Note: many1 would perhaps be a better name for this and consistent with
@@ -1052,7 +1052,7 @@ many p f = K.toParserK $ D.many (K.fromParserK p) f
1053{-# INLINE some #-}
1053{-# INLINE some #-}
1054some :: MonadCatch m => Parser m a b -> Fold m b c -> Parser m a c
1054some :: MonadCatch m => Parser m a b -> Fold m b c -> Parser m a c
1055−some p f = K.toParserK $ D.some (K.fromParserK p) f
1055+some p f = D.toParserK $ D.some (D.fromParserK p) f
1056-- some p f = manyP p (takeGE 1 f)
1056-- some p f = manyP p (takeGE 1 f)
1057-- many = countBetween 1 maxBound
1057-- many = countBetween 1 maxBound
@@ -1097,7 +1097,7 @@ count n = countBetween n n
1097manyTillP :: -- MonadCatch m =>
1097manyTillP :: -- MonadCatch m =>
1098 Parser m a b -> Parser m a x -> Parser m b c -> Parser m a c
1098 Parser m a b -> Parser m a x -> Parser m b c -> Parser m a c
1099manyTillP _p1 _p2 _f = undefined
1099manyTillP _p1 _p2 _f = undefined
1100− -- K.toParserK $ D.manyTillP (K.fromParserK p1) (K.fromParserK p2) f
1100+ -- D.toParserK $ D.manyTillP (D.fromParserK p1) (D.fromParserK p2) f
1102-- | @manyTill f collect test@ tries the parser @test@ on the input, if @test@
1102-- | @manyTill f collect test@ tries the parser @test@ on the input, if @test@
1103-- fails it backtracks and tries @collect@, after @collect@ succeeds @test@ is
1103-- fails it backtracks and tries @collect@, after @collect@ succeeds @test@ is
@@ -1113,7 +1113,7 @@ manyTillP _p1 _p2 _f = undefined
1113manyTill :: MonadCatch m
1113manyTill :: MonadCatch m
1114 => Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
1114 => Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
1115manyTill p1 p2 f =
1115manyTill p1 p2 f =
1116− K.toParserK $ D.manyTill f (K.fromParserK p1) (K.fromParserK p2)
1116+ D.toParserK $ D.manyTill f (D.fromParserK p1) (D.fromParserK p2)
1118-- | @manyThen f collect recover@ repeats the parser @collect@ on the input and
1118-- | @manyThen f collect recover@ repeats the parser @collect@ on the input and
1119-- collects the output in the supplied fold. If the the parser @collect@ fails,
1119-- collects the output in the supplied fold. If the the parser @collect@ fails,