@@ -290,7 +290,7 @@ import Prelude hiding
290290-- /Pre-release/
291291--
292292{-# INLINE toFold #-}
293−toFold :: Monad m => Parser m a b -> Fold m a b
293+toFold :: Monad m => Parser a m b -> Fold m a b
294294toFold p = D.toFold $ D.fromParserK p
295295
296296-------------------------------------------------------------------------------
@@ -300,7 +300,7 @@ toFold p = D.toFold $ D.fromParserK p
300300-- | Make a 'Parser' from a 'Fold'.
301301--
302302{-# INLINE fromFold #-}
303−fromFold :: Monad m => Fold m a b -> Parser m a b
303+fromFold :: Monad m => Fold m a b -> Parser a m b
304304fromFold = D.toParserK . D.fromFold
305305
306306-- | Convert a Maybe returning fold to an error returning parser. The first
@@ -310,7 +310,7 @@ fromFold = D.toParserK . D.fromFold
310310-- /Pre-release/
311311--
312312{-# INLINE fromFoldMaybe #-}
313−fromFoldMaybe :: Monad m => String -> Fold m a (Maybe b) -> Parser m a b
313+fromFoldMaybe :: Monad m => String -> Fold m a (Maybe b) -> Parser a m b
314314fromFoldMaybe err = D.toParserK . D.fromFoldMaybe err
315315
316316-------------------------------------------------------------------------------
@@ -322,7 +322,7 @@ fromFoldMaybe err = D.toParserK . D.fromFoldMaybe err
322322-- | A parser that always yields a pure value without consuming any input.
323323--
324324{-# INLINE [3] fromPure #-}
325−fromPure :: Monad m => b -> Parser m a b
325+fromPure :: Monad m => b -> Parser a m b
326326fromPure = D.toParserK . D.fromPure
327327{-# RULES "fromPure fallback to CPS" [2]
328328 forall a. D.toParserK (D.fromPure a) = K.fromPure a #-}
@@ -333,7 +333,7 @@ fromPure = D.toParserK . D.fromPure
333333-- consuming any input.
334334--
335335{-# INLINE fromEffect #-}
336−fromEffect :: Monad m => m b -> Parser m a b
336+fromEffect :: Monad m => m b -> Parser a m b
337337fromEffect = K.fromEffect -- D.toParserK . D.fromEffect
338338
339339-- This is the dual of "nil".
@@ -342,7 +342,7 @@ fromEffect = K.fromEffect -- D.toParserK . D.fromEffect
342342-- any input.
343343--
344344{-# INLINE [3] die #-}
345−die :: Monad m => String -> Parser m a b
345+die :: Monad m => String -> Parser a m b
346346die = D.toParserK . D.die
347347{-# RULES "die fallback to CPS" [2]
348348 forall a. D.toParserK (D.die a) = K.die a #-}
@@ -355,7 +355,7 @@ die = D.toParserK . D.die
355355-- /Pre-release/
356356--
357357{-# INLINE dieM #-}
358−dieM :: Monad m => m String -> Parser m a b
358+dieM :: Monad m => m String -> Parser a m b
359359dieM = D.toParserK . D.dieM
360360
361361-------------------------------------------------------------------------------
@@ -370,20 +370,20 @@ dieM = D.toParserK . D.dieM
370370-- > lmap = Parser.lmapM return
371371--
372372{-# INLINE lmap #-}
373−lmap :: Monad m => (a -> b) -> Parser m b r -> Parser m a r
373+lmap :: Monad m => (a -> b) -> Parser b m r -> Parser a m r
374374lmap f p = D.toParserK $ D.lmap f $ D.fromParserK p
375375
376376-- | @lmapM f parser@ maps the monadic function @f@ on the input of the parser.
377377--
378378{-# INLINE lmapM #-}
379−lmapM :: Monad m => (a -> m b) -> Parser m b r -> Parser m a r
379+lmapM :: Monad m => (a -> m b) -> Parser b m r -> Parser a m r
380380lmapM f p = D.toParserK $ D.lmapM f $ D.fromParserK p
381381
382382-- | @rmapM f parser@ maps the monadic function @f@ on the output of the parser.
383383--
384384-- >>> rmap = fmap
385385{-# INLINE rmapM #-}
386−rmapM :: Monad m => (b -> m c) -> Parser m a b -> Parser m a c
386+rmapM :: Monad m => (b -> m c) -> Parser a m b -> Parser a m c
387387rmapM f p = D.toParserK $ D.rmapM f $ D.fromParserK p
388388
389389-- | Include only those elements that pass a predicate.
@@ -392,7 +392,7 @@ rmapM f p = D.toParserK $ D.rmapM f $ D.fromParserK p
392392-- 40
393393--
394394{-# INLINE filter #-}
395−filter :: Monad m => (a -> Bool) -> Parser m a b -> Parser m a b
395+filter :: Monad m => (a -> Bool) -> Parser a m b -> Parser a m b
396396filter f p = D.toParserK $ D.filter f $ D.fromParserK p
397397
398398-------------------------------------------------------------------------------
@@ -410,7 +410,7 @@ filter f p = D.toParserK $ D.filter f $ D.fromParserK p
410410-- @
411411--
412412{-# INLINE peek #-}
413−peek :: Monad m => Parser m a a
413+peek :: Monad m => Parser a m a
414414peek = D.toParserK D.peek
415415
416416-- | Succeeds if we are at the end of input, fails otherwise.
@@ -419,7 +419,7 @@ peek = D.toParserK D.peek
419419-- (1,())
420420--
421421{-# INLINE eof #-}
422−eof :: Monad m => Parser m a ()
422+eof :: Monad m => Parser a m ()
423423eof = D.toParserK D.eof
424424
425425-- | Returns the next element if it passes the predicate, fails otherwise.
@@ -431,7 +431,7 @@ eof = D.toParserK D.eof
431431-- >>> satisfy f = Parser.maybe (toMaybe f)
432432--
433433{-# INLINE satisfy #-}
434−satisfy :: Monad m => (a -> Bool) -> Parser m a a
434+satisfy :: Monad m => (a -> Bool) -> Parser a m a
435435satisfy = D.toParserK . D.satisfy
436436
437437-- | Consume one element from the head of the stream. Fails if it encounters
@@ -440,7 +440,7 @@ satisfy = D.toParserK . D.satisfy
440440-- >>> one = Parser.satisfy $ const True
441441--
442442{-# INLINE one #-}
443−one :: Monad m => Parser m a a
443+one :: Monad m => Parser a m a
444444one = satisfy $ const True
445445
446446-- Alternate names: "only", "onlyThis".
@@ -450,7 +450,7 @@ one = satisfy $ const True
450450-- >>> oneEq x = Parser.satisfy (== x)
451451--
452452{-# INLINE oneEq #-}
453−oneEq :: (Monad m, Eq a) => a -> Parser m a a
453+oneEq :: (Monad m, Eq a) => a -> Parser a m a
454454oneEq x = satisfy (== x)
455455
456456-- Alternate names: "exclude", "notThis".
@@ -460,7 +460,7 @@ oneEq x = satisfy (== x)
460460-- >>> oneNotEq x = Parser.satisfy (/= x)
461461--
462462{-# INLINE oneNotEq #-}
463−oneNotEq :: (Monad m, Eq a) => a -> Parser m a a
463+oneNotEq :: (Monad m, Eq a) => a -> Parser a m a
464464oneNotEq x = satisfy (/= x)
465465
466466-- | Match any one of the elements in the supplied list.
@@ -484,7 +484,7 @@ oneNotEq x = satisfy (/= x)
484484-- search.
485485--
486486{-# INLINE oneOf #-}
487−oneOf :: (Monad m, Eq a, Foldable f) => f a -> Parser m a a
487+oneOf :: (Monad m, Eq a, Foldable f) => f a -> Parser a m a
488488oneOf xs = satisfy (`Foldable.elem` xs)
489489
490490-- | See performance notes in 'oneOf'.
@@ -492,7 +492,7 @@ oneOf xs = satisfy (`Foldable.elem` xs)
492492-- >>> noneOf xs = Parser.satisfy (`Foldable.notElem` xs)
493493--
494494{-# INLINE noneOf #-}
495−noneOf :: (Monad m, Eq a, Foldable f) => f a -> Parser m a a
495+noneOf :: (Monad m, Eq a, Foldable f) => f a -> Parser a m a
496496noneOf xs = satisfy (`Foldable.notElem` xs)
497497
498498-- | Return the next element of the input. Returns 'Nothing'
@@ -502,7 +502,7 @@ noneOf xs = satisfy (`Foldable.notElem` xs)
502502--
503503{-# DEPRECATED next "Please use \"fromFold Fold.one\" instead" #-}
504504{-# INLINE next #-}
505−next :: Monad m => Parser m a (Maybe a)
505+next :: Monad m => Parser a m (Maybe a)
506506next = D.toParserK D.next
507507
508508-- | Map a 'Maybe' returning function on the next element in the stream. The
@@ -517,7 +517,7 @@ next = D.toParserK D.next
517517-- /Pre-release/
518518--
519519{-# INLINE maybe #-}
520−maybe :: Monad m => (a -> Maybe b) -> Parser m a b
520+maybe :: Monad m => (a -> Maybe b) -> Parser a m b
521521maybe = D.toParserK . D.maybe
522522
523523-- | Map an 'Either' returning function on the next element in the stream. If
@@ -527,7 +527,7 @@ maybe = D.toParserK . D.maybe
527527-- /Pre-release/
528528--
529529{-# INLINE either #-}
530−either :: Monad m => (a -> Either String b) -> Parser m a b
530+either :: Monad m => (a -> Either String b) -> Parser a m b
531531either = D.toParserK . D.either
532532
533533-------------------------------------------------------------------------------
@@ -576,7 +576,7 @@ either = D.toParserK . D.either
576576--
577577{-# INLINE takeBetween #-}
578578takeBetween :: Monad m =>
579− Int -> Int -> Fold m a b -> Parser m a b
579+ Int -> Int -> Fold m a b -> Parser a m b
580580takeBetween m n = D.toParserK . D.takeBetween m n
581581
582582-- | Stops after taking exactly @n@ input elements.
@@ -589,7 +589,7 @@ takeBetween m n = D.toParserK . D.takeBetween m n
589589-- *** Exception: ParseError "takeEQ: Expecting exactly 4 elements, input terminated on 3"
590590--
591591{-# INLINE takeEQ #-}
592−takeEQ :: Monad m => Int -> Fold m a b -> Parser m a b
592+takeEQ :: Monad m => Int -> Fold m a b -> Parser a m b
593593takeEQ n = D.toParserK . D.takeEQ n
594594
595595-- | Take at least @n@ input elements, but can collect more.
@@ -607,7 +607,7 @@ takeEQ n = D.toParserK . D.takeEQ n
607607-- /Pre-release/
608608--
609609{-# INLINE takeGE #-}
610−takeGE :: Monad m => Int -> Fold m a b -> Parser m a b
610+takeGE :: Monad m => Int -> Fold m a b -> Parser a m b
611611takeGE n = D.toParserK . D.takeGE n
612612
613613-------------------------------------------------------------------------------
@@ -634,7 +634,7 @@ takeGE n = D.toParserK . D.takeGE n
634634-- /Pre-release/
635635--
636636{-# INLINE takeWhileP #-}
637−takeWhileP :: Monad m => (a -> Bool) -> Parser m a b -> Parser m a b
637+takeWhileP :: Monad m => (a -> Bool) -> Parser a m b -> Parser a m b
638638takeWhileP cond p = D.toParserK $ D.takeWhileP cond (D.fromParserK p)
639639
640640-- | Collect stream elements until an element fails the predicate. The element
@@ -655,7 +655,7 @@ takeWhileP cond p = D.toParserK $ D.takeWhileP cond (D.fromParserK p)
655655-- @
656656--
657657{-# INLINE takeWhile #-}
658−takeWhile :: Monad m => (a -> Bool) -> Fold m a b -> Parser m a b
658+takeWhile :: Monad m => (a -> Bool) -> Fold m a b -> Parser a m b
659659takeWhile cond = D.toParserK . D.takeWhile cond
660660-- takeWhile cond f = takeWhileP cond (fromFold f)
661661
@@ -664,7 +664,7 @@ takeWhile cond = D.toParserK . D.takeWhile cond
664664-- >>> takeWhile1 cond p = Parser.takeWhileP cond (Parser.takeBetween 1 maxBound p)
665665--
666666{-# INLINE takeWhile1 #-}
667−takeWhile1 :: Monad m => (a -> Bool) -> Fold m a b -> Parser m a b
667+takeWhile1 :: Monad m => (a -> Bool) -> Fold m a b -> Parser a m b
668668takeWhile1 cond = D.toParserK . D.takeWhile1 cond
669669-- takeWhile1 cond f = takeWhileP cond (takeBetween 1 maxBound f)
670670
@@ -676,7 +676,7 @@ takeWhile1 cond = D.toParserK . D.takeWhile1 cond
676676-- >>> dropWhile p = Parser.takeWhile p Fold.drain
677677--
678678{-# INLINE dropWhile #-}
679−dropWhile :: Monad m => (a -> Bool) -> Parser m a ()
679+dropWhile :: Monad m => (a -> Bool) -> Parser a m ()
680680dropWhile p = takeWhile p FL.drain
681681
682682-------------------------------------------------------------------------------
@@ -690,7 +690,7 @@ takeFramedByGeneric :: Monad m =>
690690 -> Maybe (a -> Bool)
691691 -> Maybe (a -> Bool)
692692 -> Fold m a b
693− -> Parser m a b
693+ -> Parser a m b
694694takeFramedByGeneric esc begin end f =
695695 D.toParserK $ D.takeFramedByGeneric esc begin end f
696696
@@ -712,7 +712,7 @@ takeFramedByGeneric esc begin end f =
712712-- /Pre-release/
713713--
714714{-# INLINE takeEndBy #-}
715−takeEndBy :: Monad m => (a -> Bool) -> Parser m a b -> Parser m a b
715+takeEndBy :: Monad m => (a -> Bool) -> Parser a m b -> Parser a m b
716716takeEndBy cond = D.toParserK . D.takeEndBy cond . D.fromParserK
717717-- takeEndBy = takeEndByEsc (const False)
718718
@@ -723,7 +723,7 @@ takeEndBy cond = D.toParserK . D.takeEndBy cond . D.fromParserK
723723-- /Pre-release/
724724--
725725{-# INLINE takeEndBy_ #-}
726−takeEndBy_ :: Monad m => (a -> Bool) -> Parser m a b -> Parser m a b
726+takeEndBy_ :: Monad m => (a -> Bool) -> Parser a m b -> Parser a m b
727727takeEndBy_ cond = D.toParserK . D.takeEndBy_ cond . D.fromParserK
728728{-
729729takeEndBy_ isEnd p =
@@ -736,7 +736,7 @@ takeEndBy_ isEnd p =
736736-- /Unimplemented/
737737{-# INLINE takeEitherSepBy #-}
738738takeEitherSepBy :: -- Monad m =>
739− (a -> Bool) -> Fold m (Either a b) c -> Parser m a c
739+ (a -> Bool) -> Fold m (Either a b) c -> Parser a m c
740740takeEitherSepBy _cond = undefined -- D.toParserK . D.takeEitherSepBy cond
741741
742742-- | Parse a token that starts with an element chosen by the predicate. The
@@ -764,7 +764,7 @@ takeEitherSepBy _cond = undefined -- D.toParserK . D.takeEitherSepBy cond
764764-- /Pre-release/
765765--
766766{-# INLINE takeStartBy #-}
767−takeStartBy :: Monad m => (a -> Bool) -> Fold m a b -> Parser m a b
767+takeStartBy :: Monad m => (a -> Bool) -> Fold m a b -> Parser a m b
768768takeStartBy cond = D.toParserK . D.takeStartBy cond
769769
770770-- | Like 'takeStartBy' but drops the separator.
@@ -772,7 +772,7 @@ takeStartBy cond = D.toParserK . D.takeStartBy cond
772772-- >>> takeStartBy_ isBegin = Parser.takeFramedByGeneric Nothing (Just isBegin) Nothing
773773--
774774{-# INLINE takeStartBy_ #-}
775−takeStartBy_ :: Monad m => (a -> Bool) -> Fold m a b -> Parser m a b
775+takeStartBy_ :: Monad m => (a -> Bool) -> Fold m a b -> Parser a m b
776776takeStartBy_ isBegin = takeFramedByGeneric Nothing (Just isBegin) Nothing
777777
778778-------------------------------------------------------------------------------
@@ -786,7 +786,7 @@ takeStartBy_ isBegin = takeFramedByGeneric Nothing (Just isBegin) Nothing
786786-- /pre-release/
787787{-# INLINE takeEndByEsc #-}
788788takeEndByEsc :: Monad m =>
789− (a -> Bool) -> (a -> Bool) -> Parser m a b -> Parser m a b
789+ (a -> Bool) -> (a -> Bool) -> Parser a m b -> Parser a m b
790790takeEndByEsc isEsc isEnd p =
791791 D.toParserK $ D.takeEndByEsc isEsc isEnd (D.fromParserK p)
792792
@@ -813,7 +813,7 @@ takeEndByEsc isEsc isEnd p =
813813-- /Pre-release/
814814{-# INLINE takeFramedByEsc_ #-}
815815takeFramedByEsc_ :: Monad m =>
816− (a -> Bool) -> (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser m a b
816+ (a -> Bool) -> (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser a m b
817817takeFramedByEsc_ isEsc isBegin isEnd f =
818818 D.toParserK $ D.takeFramedByEsc_ isEsc isBegin isEnd f
819819-- takeEndByEsc_ isEsc isEnd p =
@@ -826,7 +826,7 @@ takeFramedByEsc_ isEsc isBegin isEnd f =
826826--
827827{-# INLINE takeFramedBy_ #-}
828828takeFramedBy_ :: Monad m =>
829− (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser m a b
829+ (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser a m b
830830takeFramedBy_ isBegin isEnd f = D.toParserK $ D.takeFramedBy_ isBegin isEnd f
831831-- takeFramedBy_ isBegin isEnd =
832832-- takeFramedByGeneric (Just (const False)) (Just isBegin) (Just isEnd)
@@ -855,7 +855,7 @@ takeFramedBy_ isBegin isEnd f = D.toParserK $ D.takeFramedBy_ isBegin isEnd f
855855-- @
856856--
857857{-# INLINE wordBy #-}
858−wordBy :: Monad m => (a -> Bool) -> Fold m a b -> Parser m a b
858+wordBy :: Monad m => (a -> Bool) -> Fold m a b -> Parser a m b
859859wordBy f = D.toParserK . D.wordBy f
860860
861861-- | Like 'wordBy' but treats anything inside a pair of quotes as a single
@@ -884,7 +884,7 @@ wordFramedBy :: Monad m =>
884884 -> (a -> Bool) -- ^ right quote
885885 -> (a -> Bool) -- ^ word seperator
886886 -> Fold m a b
887− -> Parser m a b
887+ -> Parser a m b
888888wordFramedBy isEsc isBegin isEnd isSpc =
889889 D.toParserK . D.wordFramedBy isEsc isBegin isEnd isSpc
890890
@@ -917,7 +917,7 @@ wordQuotedBy :: (Monad m, Eq a) =>
917917 -> (a -> a) -- ^ get right quote from left quote
918918 -> (a -> Bool) -- ^ word seperator
919919 -> Fold m a b
920− -> Parser m a b
920+ -> Parser a m b
921921wordQuotedBy keepQuotes isEsc isBegin isEnd toRight isSpc =
922922 D.toParserK . D.wordQuotedBy keepQuotes isEsc isBegin isEnd toRight isSpc
923923
@@ -948,7 +948,7 @@ wordQuotedBy keepQuotes isEsc isBegin isEnd toRight isSpc =
948948-- [[3,5,4],[1,2],[0]]
949949--
950950{-# INLINE groupBy #-}
951−groupBy :: Monad m => (a -> a -> Bool) -> Fold m a b -> Parser m a b
951+groupBy :: Monad m => (a -> a -> Bool) -> Fold m a b -> Parser a m b
952952groupBy eq = D.toParserK . D.groupBy eq
953953
954954-- | Unlike 'groupBy' this combinator performs a rolling comparison of two
@@ -982,7 +982,7 @@ groupBy eq = D.toParserK . D.groupBy eq
982982-- /Pre-release/
983983--
984984{-# INLINE groupByRolling #-}
985−groupByRolling :: Monad m => (a -> a -> Bool) -> Fold m a b -> Parser m a b
985+groupByRolling :: Monad m => (a -> a -> Bool) -> Fold m a b -> Parser a m b
986986groupByRolling eq = D.toParserK . D.groupByRolling eq
987987
988988-- | Like 'groupByRolling', but if the predicate is 'True' then collects using
@@ -997,7 +997,7 @@ groupByRolling eq = D.toParserK . D.groupByRolling eq
997997-- /Pre-release/
998998{-# INLINE groupByRollingEither #-}
999999groupByRollingEither :: Monad m =>
1000− (a -> a -> Bool) -> Fold m a b -> Fold m a c -> Parser m a (Either b c)
1000+ (a -> a -> Bool) -> Fold m a b -> Fold m a c -> Parser a m (Either b c)
10011001groupByRollingEither eq f1 = D.toParserK . D.groupByRollingEither eq f1
10021002
10031003-- XXX eqBy is not a good name because we are not matching the entire stream
@@ -1010,7 +1010,7 @@ groupByRollingEither eq f1 = D.toParserK . D.groupByRollingEither eq f1
10101010-- See also: "Streamly.Data.Stream.eqBy"
10111011--
10121012{-# INLINE eqBy #-}
1013−eqBy :: Monad m => (a -> a -> Bool) -> Stream m a -> Parser m a ()
1013+eqBy :: Monad m => (a -> a -> Bool) -> Stream m a -> Parser a m ()
10141014eqBy cmp = D.toParserK . D.eqBy cmp . Stream.toStreamD
10151015
10161016-- | Match the given sequence of elements using the given comparison function.
@@ -1029,7 +1029,7 @@ eqBy cmp = D.toParserK . D.eqBy cmp . Stream.toStreamD
10291029-- *** Exception: ParseError "eqBy: mismtach occurred"
10301030--
10311031{-# INLINE listEqBy #-}
1032−listEqBy :: Monad m => (a -> a -> Bool) -> [a] -> Parser m a [a]
1032+listEqBy :: Monad m => (a -> a -> Bool) -> [a] -> Parser a m [a]
10331033-- listEqBy cmp xs = D.toParserK (D.listEqBy cmp xs)
10341034listEqBy cmp xs = eqBy cmp (Stream.fromList xs) *> fromPure xs
10351035
@@ -1040,7 +1040,7 @@ listEqBy cmp xs = eqBy cmp (Stream.fromList xs) *> fromPure xs
10401040-- >>> listEq = Parser.listEqBy (==)
10411041--
10421042{-# INLINE listEq #-}
1043−listEq :: (Monad m, Eq a) => [a] -> Parser m a [a]
1043+listEq :: (Monad m, Eq a) => [a] -> Parser a m [a]
10441044listEq = listEqBy (==)
10451045
10461046-- | Match if the input stream is a subsequence of the argument stream i.e. all
@@ -1049,7 +1049,7 @@ listEq = listEqBy (==)
10491049-- subsequence of itself.
10501050{-# INLINE subsequenceBy #-}
10511051subsequenceBy :: -- Monad m =>
1052− (a -> a -> Bool) -> Stream m a -> Parser m a ()
1052+ (a -> a -> Bool) -> Stream m a -> Parser a m ()
10531053subsequenceBy = undefined
10541054
10551055{-
@@ -1096,17 +1096,17 @@ regexPCRE = undefined
10961096-- primitives. Some common idioms are described below,
10971097--
10981098-- @
1099−-- span :: (a -> Bool) -> Fold m a b -> Fold m a b -> Parser m a b
1099+-- span :: (a -> Bool) -> Fold m a b -> Fold m a b -> Parser a m b
11001100-- span pred f1 f2 = serialWith (,) ('takeWhile' pred f1) ('fromFold' f2)
11011101-- @
11021102--
11031103-- @
1104−-- spanBy :: (a -> a -> Bool) -> Fold m a b -> Fold m a b -> Parser m a b
1104+-- spanBy :: (a -> a -> Bool) -> Fold m a b -> Fold m a b -> Parser a m b
11051105-- spanBy eq f1 f2 = serialWith (,) ('groupBy' eq f1) ('fromFold' f2)
11061106-- @
11071107--
11081108-- @
1109−-- spanByRolling :: (a -> a -> Bool) -> Fold m a b -> Fold m a b -> Parser m a b
1109+-- spanByRolling :: (a -> a -> Bool) -> Fold m a b -> Fold m a b -> Parser a m b
11101110-- spanByRolling eq f1 f2 = serialWith (,) ('groupByRolling' eq f1) ('fromFold' f2)
11111111-- @
11121112--
@@ -1114,7 +1114,7 @@ regexPCRE = undefined
11141114--
11151115{-# INLINE serialWith #-}
11161116serialWith :: Monad m
1117− => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
1117+ => (a -> b -> c) -> Parser x m a -> Parser x m b -> Parser x m c
11181118serialWith f p1 p2 =
11191119 D.toParserK $ D.serialWith f (D.fromParserK p1) (D.fromParserK p2)
11201120
@@ -1139,7 +1139,7 @@ serialWith f p1 p2 =
11391139-- /Pre-release/
11401140--
11411141{-# INLINE split_ #-}
1142−split_ :: Monad m => Parser m x a -> Parser m x b -> Parser m x b
1142+split_ :: Monad m => Parser x m a -> Parser x m b -> Parser x m b
11431143split_ p1 p2 = D.toParserK $ D.split_ (D.fromParserK p1) (D.fromParserK p2)
11441144
11451145{-
@@ -1151,7 +1151,7 @@ split_ p1 p2 = D.toParserK $ D.split_ (D.fromParserK p1) (D.fromParserK p2)
11511151--
11521152{-# INLINE teeWith #-}
11531153teeWith :: Monad m
1154− => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
1154+ => (a -> b -> c) -> Parser x m a -> Parser x m b -> Parser x m c
11551155teeWith f p1 p2 =
11561156 D.toParserK $ D.teeWith f (D.fromParserK p1) (D.fromParserK p2)
11571157
@@ -1162,7 +1162,7 @@ teeWith f p1 p2 =
11621162--
11631163{-# INLINE teeWithFst #-}
11641164teeWithFst :: Monad m
1165− => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
1165+ => (a -> b -> c) -> Parser x m a -> Parser x m b -> Parser x m c
11661166teeWithFst f p1 p2 =
11671167 D.toParserK $ D.teeWithFst f (D.fromParserK p1) (D.fromParserK p2)
11681168
@@ -1173,7 +1173,7 @@ teeWithFst f p1 p2 =
11731173--
11741174{-# INLINE teeWithMin #-}
11751175teeWithMin :: Monad m
1176− => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
1176+ => (a -> b -> c) -> Parser x m a -> Parser x m b -> Parser x m c
11771177teeWithMin f p1 p2 =
11781178 D.toParserK $ D.teeWithMin f (D.fromParserK p1) (D.fromParserK p2)
11791179-}
@@ -1196,7 +1196,7 @@ teeWithMin f p1 p2 =
11961196-- /Pre-release/
11971197--
11981198{-# INLINE alt #-}
1199−alt :: Monad m => Parser m x a -> Parser m x a -> Parser m x a
1199+alt :: Monad m => Parser x m a -> Parser x m a -> Parser x m a
12001200alt p1 p2 = D.toParserK $ D.alt (D.fromParserK p1) (D.fromParserK p2)
12011201
12021202{-
@@ -1208,7 +1208,7 @@ alt p1 p2 = D.toParserK $ D.alt (D.fromParserK p1) (D.fromParserK p2)
12081208--
12091209{-# INLINE shortest #-}
12101210shortest :: Monad m
1211− => Parser m x a -> Parser m x a -> Parser m x a
1211+ => Parser x m a -> Parser x m a -> Parser x m a
12121212shortest p1 p2 = D.toParserK $ D.shortest (D.fromParserK p1) (D.fromParserK p2)
12131213
12141214-- | Longest alternative. Apply both parsers in parallel but choose the result
@@ -1219,14 +1219,14 @@ shortest p1 p2 = D.toParserK $ D.shortest (D.fromParserK p1) (D.fromParserK p2)
12191219--
12201220{-# INLINE longest #-}
12211221longest :: Monad m
1222− => Parser m x a -> Parser m x a -> Parser m x a
1222+ => Parser x m a -> Parser x m a -> Parser x m a
12231223longest p1 p2 = D.toParserK $ D.longest (D.fromParserK p1) (D.fromParserK p2)
12241224-}
12251225
12261226-- | Run a parser without consuming the input.
12271227--
12281228{-# INLINE lookAhead #-}
1229−lookAhead :: Monad m => Parser m a b -> Parser m a b
1229+lookAhead :: Monad m => Parser a m b -> Parser a m b
12301230lookAhead p = D.toParserK $ D.lookAhead $ D.fromParserK p
12311231
12321232-- | Takes at-most @n@ input elements.
@@ -1242,7 +1242,7 @@ lookAhead p = D.toParserK $ D.lookAhead $ D.fromParserK p
12421242--
12431243-- /Internal/
12441244{-# INLINE takeP #-}
1245−takeP :: Monad m => Int -> Parser m a b -> Parser m a b
1245+takeP :: Monad m => Int -> Parser a m b -> Parser a m b
12461246takeP i p = D.toParserK $ D.takeP i $ D.fromParserK p
12471247
12481248-------------------------------------------------------------------------------
@@ -1261,7 +1261,7 @@ takeP i p = D.toParserK $ D.takeP i $ D.fromParserK p
12611261{-# INLINE concatSequence #-}
12621262concatSequence ::
12631263 Monad m =>
1264− Fold m b c -> Stream m (Parser m a b) -> Parser m a c
1264+ Fold m b c -> Stream m (Parser a m b) -> Parser a m c
12651265concatSequence f p =
12661266 let sp = fmap D.fromParserK $ Stream.toStreamD p
12671267 in D.toParserK $ D.sequence sp f
@@ -1277,7 +1277,7 @@ concatSequence f p =
12771277--
12781278{-# INLINE concatMap #-}
12791279concatMap :: Monad m
1280− => (b -> Parser m a c) -> Parser m a b -> Parser m a c
1280+ => (b -> Parser a m c) -> Parser a m b -> Parser a m c
12811281concatMap f p = D.toParserK $ D.concatMap (D.fromParserK . f) (D.fromParserK p)
12821282
12831283{-
@@ -1294,7 +1294,7 @@ concatMap f p = D.toParserK $ D.concatMap (D.fromParserK . f) (D.fromParserK p)
12941294--
12951295{-# INLINE choice #-}
12961296choice ::
1297− (Functor t, Foldable t, Monad m) => t (Parser m a b) -> Parser m a b
1297+ (Functor t, Foldable t, Monad m) => t (Parser a m b) -> Parser a m b
12981298choice ps = D.toParserK $ D.choice $ D.fromParserK <$> ps
12991299-}
13001300
@@ -1309,7 +1309,7 @@ choice ps = D.toParserK $ D.choice $ D.fromParserK <$> ps
13091309--
13101310{-# INLINE manyP #-}
13111311manyP :: -- Monad m =>
1312− Parser m a b -> Parser m b c -> Parser m a c
1312+ Parser a m b -> Parser b m c -> Parser a m c
13131313manyP _p _f = undefined -- D.toParserK $ D.manyP (D.fromParserK p) f
13141314
13151315-- | Collect zero or more parses. Apply the supplied parser repeatedly on the
@@ -1323,7 +1323,7 @@ manyP _p _f = undefined -- D.toParserK $ D.manyP (D.fromParserK p) f
13231323-- Compare with 'Control.Applicative.many'.
13241324--
13251325{-# INLINE many #-}
1326−many :: Monad m => Parser m a b -> Fold m b c -> Parser m a c
1326+many :: Monad m => Parser a m b -> Fold m b c -> Parser a m c
13271327many p f = D.toParserK $ D.many (D.fromParserK p) f
13281328
13291329-- Note: many1 would perhaps be a better name for this and consistent with
@@ -1342,7 +1342,7 @@ many p f = D.toParserK $ D.many (D.fromParserK p) f
13421342-- Compare with 'Control.Applicative.some'.
13431343--
13441344{-# INLINE some #-}
1345−some :: Monad m => Parser m a b -> Fold m b c -> Parser m a c
1345+some :: Monad m => Parser a m b -> Fold m b c -> Parser a m c
13461346some p f = D.toParserK $ D.some (D.fromParserK p) f
13471347-- some p f = manyP p (takeGE 1 f)
13481348-- some = countBetween 1 maxBound
@@ -1357,7 +1357,7 @@ some p f = D.toParserK $ D.some (D.fromParserK p) f
13571357--
13581358{-# INLINE countBetween #-}
13591359countBetween :: -- Monad m =>
1360− Int -> Int -> Parser m a b -> Fold m b c -> Parser m a c
1360+ Int -> Int -> Parser a m b -> Fold m b c -> Parser a m c
13611361countBetween _m _n _p = undefined
13621362-- countBetween m n p f = manyP p (takeBetween m n f)
13631363
@@ -1372,7 +1372,7 @@ countBetween _m _n _p = undefined
13721372--
13731373{-# INLINE count #-}
13741374count :: -- Monad m =>
1375− Int -> Parser m a b -> Fold m b c -> Parser m a c
1375+ Int -> Parser a m b -> Fold m b c -> Parser a m c
13761376count n = countBetween n n
13771377-- count n p f = manyP p (takeEQ n f)
13781378
@@ -1389,7 +1389,7 @@ count n = countBetween n n
13891389--
13901390{-# INLINE manyTillP #-}
13911391manyTillP :: -- Monad m =>
1392− Parser m a b -> Parser m a x -> Parser m b c -> Parser m a c
1392+ Parser a m b -> Parser a m x -> Parser b m c -> Parser a m c
13931393manyTillP _p1 _p2 _f = undefined
13941394 -- D.toParserK $ D.manyTillP (D.fromParserK p1) (D.fromParserK p2) f
13951395
@@ -1403,11 +1403,11 @@ manyTillP _p1 _p2 _f = undefined
14031403--
14041404{-# INLINE manyTill #-}
14051405manyTill :: Monad m
1406− => Parser m a b -- ^ Chunking parser. Parses chunks of input.
1407− -> Parser m a x -- ^ Test parser. Parsing stops when this parser succeeds
1406+ => Parser a m b -- ^ Chunking parser. Parses chunks of input.
1407+ -> Parser a m x -- ^ Test parser. Parsing stops when this parser succeeds
14081408 -- else backtract and run the chunking parser.
14091409 -> Fold m b c -- ^ Folds the output of the chunking parser.
1410− -> Parser m a c
1410+ -> Parser a m c
14111411manyTill collect test f =
14121412 D.toParserK $ D.manyTill (D.fromParserK collect) (D.fromParserK test) f
14131413
@@ -1423,7 +1423,7 @@ manyTill collect test f =
14231423--
14241424{-# INLINE manyThen #-}
14251425manyThen :: -- (Foldable t, Monad m) =>
1426− Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
1426+ Parser a m b -> Parser a m x -> Fold m b c -> Parser a m c
14271427manyThen _parser _recover _f = undefined
14281428
14291429-------------------------------------------------------------------------------
@@ -1453,10 +1453,10 @@ manyThen _parser _recover _f = undefined
14531453--
14541454{-# INLINE deintercalate #-}
14551455deintercalate :: Monad m =>
1456− Parser m a x
1457− -> Parser m a y
1456+ Parser a m x
1457+ -> Parser a m y
14581458 -> Fold m (Either x y) z
1459− -> Parser m a z
1459+ -> Parser a m z
14601460deintercalate contentL contentR sink =
14611461 D.toParserK
14621462 $ D.deintercalate
@@ -1470,7 +1470,7 @@ deintercalate contentL contentR sink =
14701470--
14711471{-# INLINE sepBy1 #-}
14721472sepBy1 :: Monad m =>
1473− Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
1473+ Parser a m b -> Parser a m x -> Fold m b c -> Parser a m c
14741474sepBy1 p sep sink = do
14751475 x <- p
14761476 f <- fromEffect $ FL.reduce sink
@@ -1486,7 +1486,7 @@ sepBy1 p sep sink = do
14861486--
14871487{-# INLINE sepBy #-}
14881488sepBy :: Monad m =>
1489− Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
1489+ Parser a m b -> Parser a m x -> Fold m b c -> Parser a m c
14901490sepBy content sep sink =
14911491 D.toParserK $ D.sepBy (D.fromParserK content) (D.fromParserK sep) sink
14921492-- sepBy sink = deintercalate (FL.lefts sink)
@@ -1503,7 +1503,7 @@ sepBy content sep sink =
15031503--
15041504{-# INLINE roundRobin #-}
15051505roundRobin :: -- (Foldable t, Monad m) =>
1506− t (Parser m a b) -> Fold m b c -> Parser m a c
1506+ t (Parser a m b) -> Fold m b c -> Parser a m c
15071507roundRobin _ps _f = undefined
15081508
15091509-------------------------------------------------------------------------------
@@ -1518,7 +1518,7 @@ roundRobin _ps _f = undefined
15181518--
15191519{-# INLINE retryMaxTotal #-}
15201520retryMaxTotal :: -- (Monad m) =>
1521− Int -> Parser m a b -> Fold m b c -> Parser m a c
1521+ Int -> Parser a m b -> Fold m b c -> Parser a m c
15221522retryMaxTotal _n _p _f = undefined
15231523
15241524-- | Like 'retryMaxTotal' but aborts after @n@ successive failures.
@@ -1527,7 +1527,7 @@ retryMaxTotal _n _p _f = undefined
15271527--
15281528{-# INLINE retryMaxSuccessive #-}
15291529retryMaxSuccessive :: -- (Monad m) =>
1530− Int -> Parser m a b -> Fold m b c -> Parser m a c
1530+ Int -> Parser a m b -> Fold m b c -> Parser a m c
15311531retryMaxSuccessive _n _p _f = undefined
15321532
15331533-- | Keep trying a parser until it succeeds. When the parser fails the input
@@ -1538,5 +1538,5 @@ retryMaxSuccessive _n _p _f = undefined
15381538--
15391539{-# INLINE retry #-}
15401540retry :: -- (Monad m) =>
1541− Parser m a b -> Parser m a b
1541+ Parser a m b -> Parser a m b
15421542retry _p = undefined