@@ -244,7 +244,7 @@ module Streamly.Internal.Data.Parser
247−import Control.Monad.Catch (MonadCatch, MonadThrow)
247+import Control.Monad.Catch (MonadThrow)
248import Data.Functor (($>))
248import Data.Functor (($>))
249import Prelude hiding
249import Prelude hiding
250 ( any, all, dropWhile, take, takeWhile, sequence, concatMap, maybe, either
250 ( any, all, dropWhile, take, takeWhile, sequence, concatMap, maybe, either
@@ -298,7 +298,7 @@ toFold p = D.toFold $ D.fromParserK p
298-- /Pre-release/
298-- /Pre-release/
300{-# INLINE fromFold #-}
300{-# INLINE fromFold #-}
301−fromFold :: MonadCatch m => Fold m a b -> Parser m a b
301+fromFold :: Monad m => Fold m a b -> Parser m a b
302fromFold = D.toParserK . D.fromFold
302fromFold = D.toParserK . D.fromFold
304-- | Convert a Maybe returning fold to an error returning parser. The first
304-- | Convert a Maybe returning fold to an error returning parser. The first
@@ -308,7 +308,7 @@ fromFold = D.toParserK . D.fromFold
308-- /Pre-release/
308-- /Pre-release/
310{-# INLINE fromFoldMaybe #-}
310{-# INLINE fromFoldMaybe #-}
311−fromFoldMaybe :: MonadCatch m => String -> Fold m a (Maybe b) -> Parser m a b
311+fromFoldMaybe :: Monad m => String -> Fold m a (Maybe b) -> Parser m a b
312fromFoldMaybe err = D.toParserK . D.fromFoldMaybe err
312fromFoldMaybe err = D.toParserK . D.fromFoldMaybe err
314-------------------------------------------------------------------------------
314-------------------------------------------------------------------------------
@@ -322,7 +322,7 @@ fromFoldMaybe err = D.toParserK . D.fromFoldMaybe err
322-- /Pre-release/
322-- /Pre-release/
324{-# INLINE [3] fromPure #-}
324{-# INLINE [3] fromPure #-}
325−fromPure :: MonadCatch m => b -> Parser m a b
325+fromPure :: Monad m => b -> Parser m a b
326fromPure = D.toParserK . D.fromPure
326fromPure = D.toParserK . D.fromPure
327{-# RULES "fromPure fallback to CPS" [2]
327{-# RULES "fromPure fallback to CPS" [2]
328 forall a. D.toParserK (D.fromPure a) = K.fromPure a #-}
328 forall a. D.toParserK (D.fromPure a) = K.fromPure a #-}
@@ -335,7 +335,7 @@ fromPure = D.toParserK . D.fromPure
335-- /Pre-release/
335-- /Pre-release/
337{-# INLINE fromEffect #-}
337{-# INLINE fromEffect #-}
338−fromEffect :: MonadCatch m => m b -> Parser m a b
338+fromEffect :: Monad m => m b -> Parser m a b
339fromEffect = K.fromEffect -- D.toParserK . D.fromEffect
339fromEffect = K.fromEffect -- D.toParserK . D.fromEffect
341-- This is the dual of "nil".
341-- This is the dual of "nil".
@@ -346,7 +346,7 @@ fromEffect = K.fromEffect -- D.toParserK . D.fromEffect
346-- /Pre-release/
346-- /Pre-release/
348{-# INLINE [3] die #-}
348{-# INLINE [3] die #-}
349−die :: MonadCatch m => String -> Parser m a b
349+die :: Monad m => String -> Parser m a b
350die = D.toParserK . D.die
350die = D.toParserK . D.die
351{-# RULES "die fallback to CPS" [2]
351{-# RULES "die fallback to CPS" [2]
352 forall a. D.toParserK (D.die a) = K.die a #-}
352 forall a. D.toParserK (D.die a) = K.die a #-}
@@ -359,7 +359,7 @@ die = D.toParserK . D.die
359-- /Pre-release/
359-- /Pre-release/
361{-# INLINE dieM #-}
361{-# INLINE dieM #-}
362−dieM :: MonadCatch m => m String -> Parser m a b
362+dieM :: Monad m => m String -> Parser m a b
363dieM = D.toParserK . D.dieM
363dieM = D.toParserK . D.dieM
365-------------------------------------------------------------------------------
365-------------------------------------------------------------------------------
@@ -375,14 +375,14 @@ dieM = D.toParserK . D.dieM
376-- /Internal/
376-- /Internal/
377{-# INLINE lmap #-}
377{-# INLINE lmap #-}
378−lmap :: MonadCatch m => (a -> b) -> Parser m b r -> Parser m a r
378+lmap :: Monad m => (a -> b) -> Parser m b r -> Parser m a r
379lmap f p = D.toParserK $ D.lmap f $ D.fromParserK p
379lmap f p = D.toParserK $ D.lmap f $ D.fromParserK p
381-- | @lmapM f parser@ maps the monadic function @f@ on the input of the parser.
381-- | @lmapM f parser@ maps the monadic function @f@ on the input of the parser.
383-- /Internal/
383-- /Internal/
384{-# INLINE lmapM #-}
384{-# INLINE lmapM #-}
385−lmapM :: MonadCatch m => (a -> m b) -> Parser m b r -> Parser m a r
385+lmapM :: Monad m => (a -> m b) -> Parser m b r -> Parser m a r
386lmapM f p = D.toParserK $ D.lmapM f $ D.fromParserK p
386lmapM f p = D.toParserK $ D.lmapM f $ D.fromParserK p
388-- | Include only those elements that pass a predicate.
388-- | Include only those elements that pass a predicate.
@@ -392,7 +392,7 @@ lmapM f p = D.toParserK $ D.lmapM f $ D.fromParserK p
393-- /Internal/
393-- /Internal/
394{-# INLINE filter #-}
394{-# INLINE filter #-}
395−filter :: MonadCatch m => (a -> Bool) -> Parser m a b -> Parser m a b
395+filter :: Monad m => (a -> Bool) -> Parser m a b -> Parser m a b
396filter f p = D.toParserK $ D.filter f $ D.fromParserK p
396filter f p = D.toParserK $ D.filter f $ D.fromParserK p
398-------------------------------------------------------------------------------
398-------------------------------------------------------------------------------
@@ -412,7 +412,7 @@ filter f p = D.toParserK $ D.filter f $ D.fromParserK p
412-- /Pre-release/
412-- /Pre-release/
414{-# INLINE peek #-}
414{-# INLINE peek #-}
415−peek :: MonadCatch m => Parser m a a
415+peek :: Monad m => Parser m a a
416peek = D.toParserK D.peek
416peek = D.toParserK D.peek
418-- | Succeeds if we are at the end of input, fails otherwise.
418-- | Succeeds if we are at the end of input, fails otherwise.
@@ -423,7 +423,7 @@ peek = D.toParserK D.peek
423-- /Pre-release/
423-- /Pre-release/
425{-# INLINE eof #-}
425{-# INLINE eof #-}
426−eof :: MonadCatch m => Parser m a ()
426+eof :: Monad m => Parser m a ()
427eof = D.toParserK D.eof
427eof = D.toParserK D.eof
429-- | Returns the next element if it passes the predicate, fails otherwise.
429-- | Returns the next element if it passes the predicate, fails otherwise.
@@ -437,7 +437,7 @@ eof = D.toParserK D.eof
437-- /Pre-release/
437-- /Pre-release/
439{-# INLINE satisfy #-}
439{-# INLINE satisfy #-}
440−satisfy :: MonadCatch m => (a -> Bool) -> Parser m a a
440+satisfy :: Monad m => (a -> Bool) -> Parser m a a
441satisfy = D.toParserK . D.satisfy
441satisfy = D.toParserK . D.satisfy
443-- | Consume one element from the head of the stream. Fails if it encounters
443-- | Consume one element from the head of the stream. Fails if it encounters
@@ -448,7 +448,7 @@ satisfy = D.toParserK . D.satisfy
448-- /Pre-release/
448-- /Pre-release/
450{-# INLINE one #-}
450{-# INLINE one #-}
451−one :: MonadCatch m => Parser m a a
451+one :: Monad m => Parser m a a
452one = satisfy $ const True
452one = satisfy $ const True
454-- | Match a specific element.
454-- | Match a specific element.
@@ -456,7 +456,7 @@ one = satisfy $ const True
456-- >>> element x = Parser.satisfy (== x)
456-- >>> element x = Parser.satisfy (== x)
458{-# INLINE element #-}
458{-# INLINE element #-}
459−element :: (MonadCatch m, Eq a) => a -> Parser m a a
459+element :: (Monad m, Eq a) => a -> Parser m a a
460element x = satisfy (== x)
460element x = satisfy (== x)
462-- | Match anything other than the supplied element.
462-- | Match anything other than the supplied element.
@@ -464,7 +464,7 @@ element x = satisfy (== x)
464-- >>> except x = Parser.satisfy (/= x)
464-- >>> except x = Parser.satisfy (/= x)
466{-# INLINE except #-}
466{-# INLINE except #-}
467−except :: (MonadCatch m, Eq a) => a -> Parser m a a
467+except :: (Monad m, Eq a) => a -> Parser m a a
468except x = satisfy (/= x)
468except x = satisfy (/= x)
470-- | Match any one of the elements in the supplied list.
470-- | Match any one of the elements in the supplied list.
@@ -488,7 +488,7 @@ except x = satisfy (/= x)
488-- search.
488-- search.
490{-# INLINE oneOf #-}
490{-# INLINE oneOf #-}
491−oneOf :: (MonadCatch m, Eq a) => [a] -> Parser m a a
491+oneOf :: (Monad m, Eq a) => [a] -> Parser m a a
492oneOf xs = satisfy (`elem` xs)
492oneOf xs = satisfy (`elem` xs)
494-- | See performance notes in 'oneOf'.
494-- | See performance notes in 'oneOf'.
@@ -496,7 +496,7 @@ oneOf xs = satisfy (`elem` xs)
496-- >>> noneOf xs = Parser.satisfy (`notElem` xs)
496-- >>> noneOf xs = Parser.satisfy (`notElem` xs)
498{-# INLINE noneOf #-}
498{-# INLINE noneOf #-}
499−noneOf :: (MonadCatch m, Eq a) => [a] -> Parser m a a
499+noneOf :: (Monad m, Eq a) => [a] -> Parser m a a
500noneOf xs = satisfy (`notElem` xs)
500noneOf xs = satisfy (`notElem` xs)
502-- | Return the next element of the input. Returns 'Nothing'
502-- | Return the next element of the input. Returns 'Nothing'
@@ -506,7 +506,7 @@ noneOf xs = satisfy (`notElem` xs)
507{-# DEPRECATED next "Please use \"fromFold Fold.one\" instead" #-}
507{-# DEPRECATED next "Please use \"fromFold Fold.one\" instead" #-}
508{-# INLINE next #-}
508{-# INLINE next #-}
509−next :: MonadCatch m => Parser m a (Maybe a)
509+next :: Monad m => Parser m a (Maybe a)
510next = D.toParserK D.next
510next = D.toParserK D.next
512-- | Map a 'Maybe' returning function on the next element in the stream. The
512-- | Map a 'Maybe' returning function on the next element in the stream. The
@@ -521,7 +521,7 @@ next = D.toParserK D.next
521-- /Pre-release/
521-- /Pre-release/
523{-# INLINE maybe #-}
523{-# INLINE maybe #-}
524−maybe :: MonadCatch m => (a -> Maybe b) -> Parser m a b
524+maybe :: Monad m => (a -> Maybe b) -> Parser m a b
525maybe = D.toParserK . D.maybe
525maybe = D.toParserK . D.maybe
527-- | Map an 'Either' returning function on the next element in the stream. If
527-- | Map an 'Either' returning function on the next element in the stream. If
@@ -531,7 +531,7 @@ maybe = D.toParserK . D.maybe
531-- /Pre-release/
531-- /Pre-release/
533{-# INLINE either #-}
533{-# INLINE either #-}
534−either :: MonadCatch m => (a -> Either String b) -> Parser m a b
534+either :: Monad m => (a -> Either String b) -> Parser m a b
535either = D.toParserK . D.either
535either = D.toParserK . D.either
537-------------------------------------------------------------------------------
537-------------------------------------------------------------------------------
@@ -579,7 +579,7 @@ either = D.toParserK . D.either
579-- /Pre-release/
579-- /Pre-release/
581{-# INLINE takeBetween #-}
581{-# INLINE takeBetween #-}
582−takeBetween :: MonadCatch m =>
582+takeBetween :: Monad m =>
583 Int -> Int -> Fold m a b -> Parser m a b
583 Int -> Int -> Fold m a b -> Parser m a b
584takeBetween m n = D.toParserK . D.takeBetween m n
584takeBetween m n = D.toParserK . D.takeBetween m n
@@ -595,7 +595,7 @@ takeBetween m n = D.toParserK . D.takeBetween m n
595-- /Pre-release/
595-- /Pre-release/
597{-# INLINE takeEQ #-}
597{-# INLINE takeEQ #-}
598−takeEQ :: MonadCatch m => Int -> Fold m a b -> Parser m a b
598+takeEQ :: Monad m => Int -> Fold m a b -> Parser m a b
599takeEQ n = D.toParserK . D.takeEQ n
599takeEQ n = D.toParserK . D.takeEQ n
601-- | Take at least @n@ input elements, but can collect more.
601-- | Take at least @n@ input elements, but can collect more.
@@ -613,7 +613,7 @@ takeEQ n = D.toParserK . D.takeEQ n
613-- /Pre-release/
613-- /Pre-release/
615{-# INLINE takeGE #-}
615{-# INLINE takeGE #-}
616−takeGE :: MonadCatch m => Int -> Fold m a b -> Parser m a b
616+takeGE :: Monad m => Int -> Fold m a b -> Parser m a b
617takeGE n = D.toParserK . D.takeGE n
617takeGE n = D.toParserK . D.takeGE n
619-------------------------------------------------------------------------------
619-------------------------------------------------------------------------------
@@ -640,7 +640,7 @@ takeGE n = D.toParserK . D.takeGE n
640-- /Pre-release/
640-- /Pre-release/
642{-# INLINE takeWhileP #-}
642{-# INLINE takeWhileP #-}
643−takeWhileP :: MonadCatch m => (a -> Bool) -> Parser m a b -> Parser m a b
643+takeWhileP :: Monad m => (a -> Bool) -> Parser m a b -> Parser m a b
644takeWhileP cond p = D.toParserK $ D.takeWhileP cond (D.fromParserK p)
644takeWhileP cond p = D.toParserK $ D.takeWhileP cond (D.fromParserK p)
646-- | Collect stream elements until an element fails the predicate. The element
646-- | Collect stream elements until an element fails the predicate. The element
@@ -663,7 +663,7 @@ takeWhileP cond p = D.toParserK $ D.takeWhileP cond (D.fromParserK p)
663-- /Pre-release/
663-- /Pre-release/
665{-# INLINE takeWhile #-}
665{-# INLINE takeWhile #-}
666−takeWhile :: MonadCatch m => (a -> Bool) -> Fold m a b -> Parser m a b
666+takeWhile :: Monad m => (a -> Bool) -> Fold m a b -> Parser m a b
667takeWhile cond = D.toParserK . D.takeWhile cond
667takeWhile cond = D.toParserK . D.takeWhile cond
668-- takeWhile cond f = takeWhileP cond (fromFold f)
668-- takeWhile cond f = takeWhileP cond (fromFold f)
@@ -674,7 +674,7 @@ takeWhile cond = D.toParserK . D.takeWhile cond
674-- /Pre-release/
674-- /Pre-release/
676{-# INLINE takeWhile1 #-}
676{-# INLINE takeWhile1 #-}
677−takeWhile1 :: MonadCatch m => (a -> Bool) -> Fold m a b -> Parser m a b
677+takeWhile1 :: Monad m => (a -> Bool) -> Fold m a b -> Parser m a b
678takeWhile1 cond = D.toParserK . D.takeWhile1 cond
678takeWhile1 cond = D.toParserK . D.takeWhile1 cond
679-- takeWhile1 cond f = takeWhileP cond (takeBetween 1 maxBound f)
679-- takeWhile1 cond f = takeWhileP cond (takeBetween 1 maxBound f)
@@ -688,7 +688,7 @@ takeWhile1 cond = D.toParserK . D.takeWhile1 cond
688-- /Pre-release/
688-- /Pre-release/
690{-# INLINE dropWhile #-}
690{-# INLINE dropWhile #-}
691−dropWhile :: MonadCatch m => (a -> Bool) -> Parser m a ()
691+dropWhile :: Monad m => (a -> Bool) -> Parser m a ()
692dropWhile p = takeWhile p FL.drain
692dropWhile p = takeWhile p FL.drain
694-------------------------------------------------------------------------------
694-------------------------------------------------------------------------------
@@ -697,7 +697,7 @@ dropWhile p = takeWhile p FL.drain
698-- XXX We can remove Maybe from esc
698-- XXX We can remove Maybe from esc
699{-# INLINE takeFramedByGeneric #-}
699{-# INLINE takeFramedByGeneric #-}
700−takeFramedByGeneric :: MonadCatch m =>
700+takeFramedByGeneric :: Monad m =>
701 Maybe (a -> Bool)
701 Maybe (a -> Bool)
702 -> Maybe (a -> Bool)
702 -> Maybe (a -> Bool)
703 -> Maybe (a -> Bool)
703 -> Maybe (a -> Bool)
@@ -724,7 +724,7 @@ takeFramedByGeneric esc begin end f =
724-- /Pre-release/
724-- /Pre-release/
726{-# INLINE takeEndBy #-}
726{-# INLINE takeEndBy #-}
727−takeEndBy :: MonadCatch m => (a -> Bool) -> Parser m a b -> Parser m a b
727+takeEndBy :: Monad m => (a -> Bool) -> Parser m a b -> Parser m a b
728takeEndBy cond = D.toParserK . D.takeEndBy cond . D.fromParserK
728takeEndBy cond = D.toParserK . D.takeEndBy cond . D.fromParserK
729-- takeEndBy = takeEndByEsc (const False)
729-- takeEndBy = takeEndByEsc (const False)
@@ -735,7 +735,7 @@ takeEndBy cond = D.toParserK . D.takeEndBy cond . D.fromParserK
735-- /Pre-release/
735-- /Pre-release/
737{-# INLINE takeEndBy_ #-}
737{-# INLINE takeEndBy_ #-}
738−takeEndBy_ :: MonadCatch m => (a -> Bool) -> Parser m a b -> Parser m a b
738+takeEndBy_ :: Monad m => (a -> Bool) -> Parser m a b -> Parser m a b
739takeEndBy_ cond = D.toParserK . D.takeEndBy_ cond . D.fromParserK
739takeEndBy_ cond = D.toParserK . D.takeEndBy_ cond . D.fromParserK
741takeEndBy_ isEnd p =
741takeEndBy_ isEnd p =
@@ -747,7 +747,7 @@ takeEndBy_ isEnd p =
748-- /Unimplemented/
748-- /Unimplemented/
749{-# INLINE takeEitherSepBy #-}
749{-# INLINE takeEitherSepBy #-}
750−takeEitherSepBy :: -- MonadCatch m =>
750+takeEitherSepBy :: -- Monad m =>
751 (a -> Bool) -> Fold m (Either a b) c -> Parser m a c
751 (a -> Bool) -> Fold m (Either a b) c -> Parser m a c
752takeEitherSepBy _cond = undefined -- D.toParserK . D.takeEitherSepBy cond
752takeEitherSepBy _cond = undefined -- D.toParserK . D.takeEitherSepBy cond
@@ -776,7 +776,7 @@ takeEitherSepBy _cond = undefined -- D.toParserK . D.takeEitherSepBy cond
776-- /Pre-release/
776-- /Pre-release/
778{-# INLINE takeStartBy #-}
778{-# INLINE takeStartBy #-}
779−takeStartBy :: MonadCatch m => (a -> Bool) -> Fold m a b -> Parser m a b
779+takeStartBy :: Monad m => (a -> Bool) -> Fold m a b -> Parser m a b
780takeStartBy cond = D.toParserK . D.takeStartBy cond
780takeStartBy cond = D.toParserK . D.takeStartBy cond
782-- | Like 'takeStartBy' but drops the separator.
782-- | Like 'takeStartBy' but drops the separator.
@@ -784,7 +784,7 @@ takeStartBy cond = D.toParserK . D.takeStartBy cond
784-- >>> takeStartBy_ isBegin = Parser.takeFramedByGeneric Nothing (Just isBegin) Nothing
784-- >>> takeStartBy_ isBegin = Parser.takeFramedByGeneric Nothing (Just isBegin) Nothing
786{-# INLINE takeStartBy_ #-}
786{-# INLINE takeStartBy_ #-}
787−takeStartBy_ :: MonadCatch m => (a -> Bool) -> Fold m a b -> Parser m a b
787+takeStartBy_ :: Monad m => (a -> Bool) -> Fold m a b -> Parser m a b
788takeStartBy_ isBegin = takeFramedByGeneric Nothing (Just isBegin) Nothing
788takeStartBy_ isBegin = takeFramedByGeneric Nothing (Just isBegin) Nothing
790-------------------------------------------------------------------------------
790-------------------------------------------------------------------------------
@@ -797,7 +797,7 @@ takeStartBy_ isBegin = takeFramedByGeneric Nothing (Just isBegin) Nothing
798-- /pre-release/
798-- /pre-release/
799{-# INLINE takeEndByEsc #-}
799{-# INLINE takeEndByEsc #-}
800−takeEndByEsc :: MonadCatch m =>
800+takeEndByEsc :: Monad m =>
801 (a -> Bool) -> (a -> Bool) -> Parser m a b -> Parser m a b
801 (a -> Bool) -> (a -> Bool) -> Parser m a b -> Parser m a b
802takeEndByEsc isEsc isEnd p =
802takeEndByEsc isEsc isEnd p =
803 D.toParserK $ D.takeEndByEsc isEsc isEnd (D.fromParserK p)
803 D.toParserK $ D.takeEndByEsc isEsc isEnd (D.fromParserK p)
@@ -824,7 +824,7 @@ takeEndByEsc isEsc isEnd p =
825-- /Pre-release/
825-- /Pre-release/
826{-# INLINE takeFramedByEsc_ #-}
826{-# INLINE takeFramedByEsc_ #-}
827−takeFramedByEsc_ :: MonadCatch m =>
827+takeFramedByEsc_ :: Monad m =>
828 (a -> Bool) -> (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser m a b
828 (a -> Bool) -> (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser m a b
829takeFramedByEsc_ isEsc isBegin isEnd f =
829takeFramedByEsc_ isEsc isBegin isEnd f =
830 D.toParserK $ D.takeFramedByEsc_ isEsc isBegin isEnd f
830 D.toParserK $ D.takeFramedByEsc_ isEsc isBegin isEnd f
@@ -837,7 +837,7 @@ takeFramedByEsc_ isEsc isBegin isEnd f =
837-- >>> takeFramedBy_ = Parser.takeFramedByEsc_ (const False)
837-- >>> takeFramedBy_ = Parser.takeFramedByEsc_ (const False)
839{-# INLINE takeFramedBy_ #-}
839{-# INLINE takeFramedBy_ #-}
840−takeFramedBy_ :: MonadCatch m =>
840+takeFramedBy_ :: Monad m =>
841 (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser m a b
841 (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser m a b
842takeFramedBy_ isBegin isEnd f = D.toParserK $ D.takeFramedBy_ isBegin isEnd f
842takeFramedBy_ isBegin isEnd f = D.toParserK $ D.takeFramedBy_ isBegin isEnd f
843-- takeFramedBy_ isBegin isEnd =
843-- takeFramedBy_ isBegin isEnd =
@@ -867,7 +867,7 @@ takeFramedBy_ isBegin isEnd f = D.toParserK $ D.takeFramedBy_ isBegin isEnd f
869{-# INLINE wordBy #-}
869{-# INLINE wordBy #-}
870−wordBy :: MonadCatch m => (a -> Bool) -> Fold m a b -> Parser m a b
870+wordBy :: Monad m => (a -> Bool) -> Fold m a b -> Parser m a b
871wordBy f = D.toParserK . D.wordBy f
871wordBy f = D.toParserK . D.wordBy f
873-- | Like 'wordBy' but treats anything inside a pair of quotes as a single
873-- | Like 'wordBy' but treats anything inside a pair of quotes as a single
@@ -891,7 +891,7 @@ wordBy f = D.toParserK . D.wordBy f
892-- /Pre-release/
892-- /Pre-release/
893{-# INLINE wordFramedBy #-}
893{-# INLINE wordFramedBy #-}
894−wordFramedBy :: MonadCatch m =>
894+wordFramedBy :: Monad m =>
895 (a -> Bool) -- ^ Escape
895 (a -> Bool) -- ^ Escape
896 -> (a -> Bool) -- ^ left quote
896 -> (a -> Bool) -- ^ left quote
897 -> (a -> Bool) -- ^ right quote
897 -> (a -> Bool) -- ^ right quote
@@ -922,7 +922,7 @@ wordFramedBy isEsc isBegin isEnd isSpc =
922-- "a\"b'c\";'d\"e'f"
922-- "a\"b'c\";'d\"e'f"
924{-# INLINE wordQuotedBy #-}
924{-# INLINE wordQuotedBy #-}
925−wordQuotedBy :: (MonadCatch m, Eq a) =>
925+wordQuotedBy :: (Monad m, Eq a) =>
926 Bool -- ^ keep the quotes in the output
926 Bool -- ^ keep the quotes in the output
927 -> (a -> Bool) -- ^ Escape
927 -> (a -> Bool) -- ^ Escape
928 -> (a -> Bool) -- ^ left quote
928 -> (a -> Bool) -- ^ left quote
@@ -963,7 +963,7 @@ wordQuotedBy keepQuotes isEsc isBegin isEnd toRight isSpc =
963-- /Pre-release/
963-- /Pre-release/
965{-# INLINE groupBy #-}
965{-# INLINE groupBy #-}
966−groupBy :: MonadCatch m => (a -> a -> Bool) -> Fold m a b -> Parser m a b
966+groupBy :: Monad m => (a -> a -> Bool) -> Fold m a b -> Parser m a b
967groupBy eq = D.toParserK . D.groupBy eq
967groupBy eq = D.toParserK . D.groupBy eq
969-- | Unlike 'groupBy' this combinator performs a rolling comparison of two
969-- | Unlike 'groupBy' this combinator performs a rolling comparison of two
@@ -997,7 +997,7 @@ groupBy eq = D.toParserK . D.groupBy eq
997-- /Pre-release/
997-- /Pre-release/
999{-# INLINE groupByRolling #-}
999{-# INLINE groupByRolling #-}
1000−groupByRolling :: MonadCatch m => (a -> a -> Bool) -> Fold m a b -> Parser m a b
1000+groupByRolling :: Monad m => (a -> a -> Bool) -> Fold m a b -> Parser m a b
1001groupByRolling eq = D.toParserK . D.groupByRolling eq
1001groupByRolling eq = D.toParserK . D.groupByRolling eq
1003-- | Like 'groupByRolling', but if the predicate is 'True' then collects using
1003-- | Like 'groupByRolling', but if the predicate is 'True' then collects using
@@ -1011,7 +1011,7 @@ groupByRolling eq = D.toParserK . D.groupByRolling eq
1012-- /Unimplemented/
1012-- /Unimplemented/
1013{-# INLINE groupByRollingEither #-}
1013{-# INLINE groupByRollingEither #-}
1014−groupByRollingEither :: MonadCatch m =>
1014+groupByRollingEither :: Monad m =>
1015 (a -> a -> Bool) -> Fold m a b -> Fold m a c -> Parser m a (Either b c)
1015 (a -> a -> Bool) -> Fold m a b -> Fold m a c -> Parser m a (Either b c)
1016groupByRollingEither eq f1 = D.toParserK . D.groupByRollingEither eq f1
1016groupByRollingEither eq f1 = D.toParserK . D.groupByRollingEither eq f1
@@ -1027,7 +1027,7 @@ groupByRollingEither eq f1 = D.toParserK . D.groupByRollingEither eq f1
1027-- /Pre-release/
1027-- /Pre-release/
1029{-# INLINE eqBy #-}
1029{-# INLINE eqBy #-}
1030−eqBy :: MonadCatch m => (a -> a -> Bool) -> [a] -> Parser m a ()
1030+eqBy :: Monad m => (a -> a -> Bool) -> [a] -> Parser m a ()
1031eqBy cmp = D.toParserK . D.eqBy cmp
1031eqBy cmp = D.toParserK . D.eqBy cmp
1033-- | Match the input sequence with the supplied list and return it if
1033-- | Match the input sequence with the supplied list and return it if
@@ -1035,7 +1035,7 @@ eqBy cmp = D.toParserK . D.eqBy cmp
1036-- /Pre-release/
1036-- /Pre-release/
1037{-# INLINE list #-}
1037{-# INLINE list #-}
1038−list :: (MonadCatch m, Eq a) => [a] -> Parser m a [a]
1038+list :: (Monad m, Eq a) => [a] -> Parser m a [a]
1039list xs = eqBy (==) xs $> xs
1039list xs = eqBy (==) xs $> xs
1041-------------------------------------------------------------------------------
1041-------------------------------------------------------------------------------
@@ -1085,7 +1085,7 @@ list xs = eqBy (==) xs $> xs
1085-- /Pre-release/
1085-- /Pre-release/
1087{-# INLINE serialWith #-}
1087{-# INLINE serialWith #-}
1088−serialWith :: MonadCatch m
1088+serialWith :: Monad m
1089 => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
1089 => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
1090serialWith f p1 p2 =
1090serialWith f p1 p2 =
1091 D.toParserK $ D.serialWith f (D.fromParserK p1) (D.fromParserK p2)
1091 D.toParserK $ D.serialWith f (D.fromParserK p1) (D.fromParserK p2)
@@ -1111,7 +1111,7 @@ serialWith f p1 p2 =
1111-- /Pre-release/
1111-- /Pre-release/
1113{-# INLINE split_ #-}
1113{-# INLINE split_ #-}
1114−split_ :: MonadCatch m => Parser m x a -> Parser m x b -> Parser m x b
1114+split_ :: Monad m => Parser m x a -> Parser m x b -> Parser m x b
1115split_ p1 p2 = D.toParserK $ D.split_ (D.fromParserK p1) (D.fromParserK p2)
1115split_ p1 p2 = D.toParserK $ D.split_ (D.fromParserK p1) (D.fromParserK p2)
@@ -1122,7 +1122,7 @@ split_ p1 p2 = D.toParserK $ D.split_ (D.fromParserK p1) (D.fromParserK p2)
1122-- /Pre-release/
1122-- /Pre-release/
1124{-# INLINE teeWith #-}
1124{-# INLINE teeWith #-}
1125−teeWith :: MonadCatch m
1125+teeWith :: Monad m
1126 => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
1126 => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
1127teeWith f p1 p2 =
1127teeWith f p1 p2 =
1128 D.toParserK $ D.teeWith f (D.fromParserK p1) (D.fromParserK p2)
1128 D.toParserK $ D.teeWith f (D.fromParserK p1) (D.fromParserK p2)
@@ -1133,7 +1133,7 @@ teeWith f p1 p2 =
1133-- /Pre-release/
1133-- /Pre-release/
1135{-# INLINE teeWithFst #-}
1135{-# INLINE teeWithFst #-}
1136−teeWithFst :: MonadCatch m
1136+teeWithFst :: Monad m
1137 => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
1137 => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
1138teeWithFst f p1 p2 =
1138teeWithFst f p1 p2 =
1139 D.toParserK $ D.teeWithFst f (D.fromParserK p1) (D.fromParserK p2)
1139 D.toParserK $ D.teeWithFst f (D.fromParserK p1) (D.fromParserK p2)
@@ -1144,7 +1144,7 @@ teeWithFst f p1 p2 =
1144-- /Unimplemented/
1144-- /Unimplemented/
1146{-# INLINE teeWithMin #-}
1146{-# INLINE teeWithMin #-}
1147−teeWithMin :: MonadCatch m
1147+teeWithMin :: Monad m
1148 => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
1148 => (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
1149teeWithMin f p1 p2 =
1149teeWithMin f p1 p2 =
1150 D.toParserK $ D.teeWithMin f (D.fromParserK p1) (D.fromParserK p2)
1150 D.toParserK $ D.teeWithMin f (D.fromParserK p1) (D.fromParserK p2)
@@ -1168,7 +1168,7 @@ teeWithMin f p1 p2 =
1168-- /Pre-release/
1168-- /Pre-release/
1170{-# INLINE alt #-}
1170{-# INLINE alt #-}
1171−alt :: MonadCatch m => Parser m x a -> Parser m x a -> Parser m x a
1171+alt :: Monad m => Parser m x a -> Parser m x a -> Parser m x a
1172alt p1 p2 = D.toParserK $ D.alt (D.fromParserK p1) (D.fromParserK p2)
1172alt p1 p2 = D.toParserK $ D.alt (D.fromParserK p1) (D.fromParserK p2)
@@ -1179,7 +1179,7 @@ alt p1 p2 = D.toParserK $ D.alt (D.fromParserK p1) (D.fromParserK p2)
1179-- /Pre-release/
1179-- /Pre-release/
1181{-# INLINE shortest #-}
1181{-# INLINE shortest #-}
1182−shortest :: MonadCatch m
1182+shortest :: Monad m
1183 => Parser m x a -> Parser m x a -> Parser m x a
1183 => Parser m x a -> Parser m x a -> Parser m x a
1184shortest p1 p2 = D.toParserK $ D.shortest (D.fromParserK p1) (D.fromParserK p2)
1184shortest p1 p2 = D.toParserK $ D.shortest (D.fromParserK p1) (D.fromParserK p2)
@@ -1190,7 +1190,7 @@ shortest p1 p2 = D.toParserK $ D.shortest (D.fromParserK p1) (D.fromParserK p2)
1190-- /Pre-release/
1190-- /Pre-release/
1192{-# INLINE longest #-}
1192{-# INLINE longest #-}
1193−longest :: MonadCatch m
1193+longest :: Monad m
1194 => Parser m x a -> Parser m x a -> Parser m x a
1194 => Parser m x a -> Parser m x a -> Parser m x a
1195longest p1 p2 = D.toParserK $ D.longest (D.fromParserK p1) (D.fromParserK p2)
1195longest p1 p2 = D.toParserK $ D.longest (D.fromParserK p1) (D.fromParserK p2)
@@ -1200,7 +1200,7 @@ longest p1 p2 = D.toParserK $ D.longest (D.fromParserK p1) (D.fromParserK p2)
1200-- /Pre-release/
1200-- /Pre-release/
1202{-# INLINE lookAhead #-}
1202{-# INLINE lookAhead #-}
1203−lookAhead :: MonadCatch m => Parser m a b -> Parser m a b
1203+lookAhead :: Monad m => Parser m a b -> Parser m a b
1204lookAhead p = D.toParserK $ D.lookAhead $ D.fromParserK p
1204lookAhead p = D.toParserK $ D.lookAhead $ D.fromParserK p
1206-- | Takes at-most @n@ input elements.
1206-- | Takes at-most @n@ input elements.
@@ -1216,7 +1216,7 @@ lookAhead p = D.toParserK $ D.lookAhead $ D.fromParserK p
1217-- /Internal/
1217-- /Internal/
1218{-# INLINE takeP #-}
1218{-# INLINE takeP #-}
1219−takeP :: MonadCatch m => Int -> Parser m a b -> Parser m a b
1219+takeP :: Monad m => Int -> Parser m a b -> Parser m a b
1220takeP i p = D.toParserK $ D.takeP i $ D.fromParserK p
1220takeP i p = D.toParserK $ D.takeP i $ D.fromParserK p
1222-------------------------------------------------------------------------------
1222-------------------------------------------------------------------------------
@@ -1234,7 +1234,7 @@ takeP i p = D.toParserK $ D.takeP i $ D.fromParserK p
1235{-# INLINE concatSequence #-}
1235{-# INLINE concatSequence #-}
1236concatSequence ::
1236concatSequence ::
1237− MonadCatch m =>
1237+ Monad m =>
1238 Fold m b c -> Stream m (Parser m a b) -> Parser m a c
1238 Fold m b c -> Stream m (Parser m a b) -> Parser m a c
1239concatSequence f p =
1239concatSequence f p =
1240 let sp = fmap D.fromParserK $ Stream.toStreamD p
1240 let sp = fmap D.fromParserK $ Stream.toStreamD p
@@ -1250,7 +1250,7 @@ concatSequence f p =
1250-- /Pre-release/
1250-- /Pre-release/
1252{-# INLINE concatMap #-}
1252{-# INLINE concatMap #-}
1253−concatMap :: MonadCatch m
1253+concatMap :: Monad m
1254 => (b -> Parser m a c) -> Parser m a b -> Parser m a c
1254 => (b -> Parser m a c) -> Parser m a b -> Parser m a c
1255concatMap f p = D.toParserK $ D.concatMap (D.fromParserK . f) (D.fromParserK p)
1255concatMap f p = D.toParserK $ D.concatMap (D.fromParserK . f) (D.fromParserK p)
@@ -1268,7 +1268,7 @@ concatMap f p = D.toParserK $ D.concatMap (D.fromParserK . f) (D.fromParserK p)
1269{-# INLINE choice #-}
1269{-# INLINE choice #-}
1270choice ::
1270choice ::
1271− (Functor t, Foldable t, MonadCatch m) => t (Parser m a b) -> Parser m a b
1271+ (Functor t, Foldable t, Monad m) => t (Parser m a b) -> Parser m a b
1272choice ps = D.toParserK $ D.choice $ D.fromParserK <$> ps
1272choice ps = D.toParserK $ D.choice $ D.fromParserK <$> ps
@@ -1282,7 +1282,7 @@ choice ps = D.toParserK $ D.choice $ D.fromParserK <$> ps
1282-- /Unimplemented/
1282-- /Unimplemented/
1284{-# INLINE manyP #-}
1284{-# INLINE manyP #-}
1285−manyP :: -- MonadCatch m =>
1285+manyP :: -- Monad m =>
1286 Parser m a b -> Parser m b c -> Parser m a c
1286 Parser m a b -> Parser m b c -> Parser m a c
1287manyP _p _f = undefined -- D.toParserK $ D.manyP (D.fromParserK p) f
1287manyP _p _f = undefined -- D.toParserK $ D.manyP (D.fromParserK p) f
@@ -1299,7 +1299,7 @@ manyP _p _f = undefined -- D.toParserK $ D.manyP (D.fromParserK p) f
1299-- /Pre-release/
1299-- /Pre-release/
1301{-# INLINE many #-}
1301{-# INLINE many #-}
1302−many :: MonadCatch m => Parser m a b -> Fold m b c -> Parser m a c
1302+many :: Monad m => Parser m a b -> Fold m b c -> Parser m a c
1303many p f = D.toParserK $ D.many (D.fromParserK p) f
1303many p f = D.toParserK $ D.many (D.fromParserK p) f
1305-- Note: many1 would perhaps be a better name for this and consistent with
1305-- Note: many1 would perhaps be a better name for this and consistent with
@@ -1320,7 +1320,7 @@ many p f = D.toParserK $ D.many (D.fromParserK p) f
1320-- /Pre-release/
1320-- /Pre-release/
1322{-# INLINE some #-}
1322{-# INLINE some #-}
1323−some :: MonadCatch m => Parser m a b -> Fold m b c -> Parser m a c
1323+some :: Monad m => Parser m a b -> Fold m b c -> Parser m a c
1324some p f = D.toParserK $ D.some (D.fromParserK p) f
1324some p f = D.toParserK $ D.some (D.fromParserK p) f
1325-- some p f = manyP p (takeGE 1 f)
1325-- some p f = manyP p (takeGE 1 f)
1326-- some = countBetween 1 maxBound
1326-- some = countBetween 1 maxBound
@@ -1334,7 +1334,7 @@ some p f = D.toParserK $ D.some (D.fromParserK p) f
1334-- /Unimplemented/
1334-- /Unimplemented/
1336{-# INLINE countBetween #-}
1336{-# INLINE countBetween #-}
1337−countBetween :: -- MonadCatch m =>
1337+countBetween :: -- Monad m =>
1338 Int -> Int -> Parser m a b -> Fold m b c -> Parser m a c
1338 Int -> Int -> Parser m a b -> Fold m b c -> Parser m a c
1339countBetween _m _n _p = undefined
1339countBetween _m _n _p = undefined
1340-- countBetween m n p f = manyP p (takeBetween m n f)
1340-- countBetween m n p f = manyP p (takeBetween m n f)
@@ -1349,7 +1349,7 @@ countBetween _m _n _p = undefined
1349-- /Unimplemented/
1349-- /Unimplemented/
1351{-# INLINE count #-}
1351{-# INLINE count #-}
1352−count :: -- MonadCatch m =>
1352+count :: -- Monad m =>
1353 Int -> Parser m a b -> Fold m b c -> Parser m a c
1353 Int -> Parser m a b -> Fold m b c -> Parser m a c
1354count n = countBetween n n
1354count n = countBetween n n
1355-- count n p f = manyP p (takeEQ n f)
1355-- count n p f = manyP p (takeEQ n f)
@@ -1366,7 +1366,7 @@ count n = countBetween n n
1366-- /Unimplemented/
1366-- /Unimplemented/
1368{-# INLINE manyTillP #-}
1368{-# INLINE manyTillP #-}
1369−manyTillP :: -- MonadCatch m =>
1369+manyTillP :: -- Monad m =>
1370 Parser m a b -> Parser m a x -> Parser m b c -> Parser m a c
1370 Parser m a b -> Parser m a x -> Parser m b c -> Parser m a c
1371manyTillP _p1 _p2 _f = undefined
1371manyTillP _p1 _p2 _f = undefined
1372 -- D.toParserK $ D.manyTillP (D.fromParserK p1) (D.fromParserK p2) f
1372 -- D.toParserK $ D.manyTillP (D.fromParserK p1) (D.fromParserK p2) f
@@ -1382,7 +1382,7 @@ manyTillP _p1 _p2 _f = undefined
1382-- /Pre-release/
1382-- /Pre-release/
1384{-# INLINE manyTill #-}
1384{-# INLINE manyTill #-}
1385−manyTill :: MonadCatch m
1385+manyTill :: Monad m
1386 => Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
1386 => Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
1387manyTill p1 p2 f =
1387manyTill p1 p2 f =
1388 D.toParserK $ D.manyTill f (D.fromParserK p1) (D.fromParserK p2)
1388 D.toParserK $ D.manyTill f (D.fromParserK p1) (D.fromParserK p2)
@@ -1398,7 +1398,7 @@ manyTill p1 p2 f =
1398-- /Unimplemented/
1398-- /Unimplemented/
1400{-# INLINE manyThen #-}
1400{-# INLINE manyThen #-}
1401−manyThen :: -- (Foldable t, MonadCatch m) =>
1401+manyThen :: -- (Foldable t, Monad m) =>
1402 Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
1402 Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
1403manyThen _parser _recover _f = undefined
1403manyThen _parser _recover _f = undefined
@@ -1432,7 +1432,7 @@ manyThen _parser _recover _f = undefined
1432-- /Pre-release/
1432-- /Pre-release/
1434{-# INLINE deintercalate #-}
1434{-# INLINE deintercalate #-}
1435−deintercalate :: MonadCatch m =>
1435+deintercalate :: Monad m =>
1436 Fold m (Either x y) z
1436 Fold m (Either x y) z
1437 -> Parser m a x
1437 -> Parser m a x
1438 -> Parser m a y
1438 -> Parser m a y
@@ -1449,7 +1449,7 @@ deintercalate sink contentL contentR =
1449-- input. Detection of that would make the implementation more complex.
1449-- input. Detection of that would make the implementation more complex.
1451{-# INLINE sepBy1 #-}
1451{-# INLINE sepBy1 #-}
1452−sepBy1 :: MonadCatch m =>
1452+sepBy1 :: Monad m =>
1453 Fold m b c -> Parser m a b -> Parser m a x -> Parser m a c
1453 Fold m b c -> Parser m a b -> Parser m a x -> Parser m a c
1454sepBy1 sink p sep = do
1454sepBy1 sink p sep = do
@@ -1465,7 +1465,7 @@ sepBy1 sink p sep = do
1465-- >>> sepBy sink content sep = Parser.sepBy1 sink content sep <|> return mempty
1465-- >>> sepBy sink content sep = Parser.sepBy1 sink content sep <|> return mempty
1467{-# INLINE sepBy #-}
1467{-# INLINE sepBy #-}
1468−sepBy :: MonadCatch m =>
1468+sepBy :: Monad m =>
1469 Fold m b c -> Parser m a b -> Parser m a x -> Parser m a c
1469 Fold m b c -> Parser m a b -> Parser m a x -> Parser m a c
1470sepBy sink content sep =
1470sepBy sink content sep =
1471 D.toParserK $ D.sepBy sink (D.fromParserK content) (D.fromParserK sep)
1471 D.toParserK $ D.sepBy sink (D.fromParserK content) (D.fromParserK sep)
@@ -1482,7 +1482,7 @@ sepBy sink content sep =
1482-- /Unimplemented/
1482-- /Unimplemented/
1484{-# INLINE roundRobin #-}
1484{-# INLINE roundRobin #-}
1485−roundRobin :: -- (Foldable t, MonadCatch m) =>
1485+roundRobin :: -- (Foldable t, Monad m) =>
1486 t (Parser m a b) -> Fold m b c -> Parser m a c
1486 t (Parser m a b) -> Fold m b c -> Parser m a c
1487roundRobin _ps _f = undefined
1487roundRobin _ps _f = undefined
@@ -1497,7 +1497,7 @@ roundRobin _ps _f = undefined
1497-- /Unimplemented/
1497-- /Unimplemented/
1499{-# INLINE retryMaxTotal #-}
1499{-# INLINE retryMaxTotal #-}
1500−retryMaxTotal :: -- (MonadCatch m) =>
1500+retryMaxTotal :: -- (Monad m) =>
1501 Int -> Parser m a b -> Fold m b c -> Parser m a c
1501 Int -> Parser m a b -> Fold m b c -> Parser m a c
1502retryMaxTotal _n _p _f = undefined
1502retryMaxTotal _n _p _f = undefined
@@ -1506,7 +1506,7 @@ retryMaxTotal _n _p _f = undefined
1506-- /Unimplemented/
1506-- /Unimplemented/
1508{-# INLINE retryMaxSuccessive #-}
1508{-# INLINE retryMaxSuccessive #-}
1509−retryMaxSuccessive :: -- (MonadCatch m) =>
1509+retryMaxSuccessive :: -- (Monad m) =>
1510 Int -> Parser m a b -> Fold m b c -> Parser m a c
1510 Int -> Parser m a b -> Fold m b c -> Parser m a c
1511retryMaxSuccessive _n _p _f = undefined
1511retryMaxSuccessive _n _p _f = undefined
@@ -1517,6 +1517,6 @@ retryMaxSuccessive _n _p _f = undefined
1517-- /Unimplemented/
1517-- /Unimplemented/
1519{-# INLINE retry #-}
1519{-# INLINE retry #-}
1520−retry :: -- (MonadCatch m) =>
1520+retry :: -- (Monad m) =>
1521 Parser m a b -> Parser m a b
1521 Parser m a b -> Parser m a b
1522retry _p = undefined
1522retry _p = undefined