{-# OPTIONS_GHC -Wno-orphans #-}
module Streamly.Internal.Data.Parser
(
K.Parser (..)
, D.ParseError (..)
, D.Step (..)
, toFold
, fromFold
, fromPure
, fromEffect
, die
, dieM
, peek
, eof
, satisfy
, next
, maybe
, either
, takeBetween
, takeEQ
, takeGE
, takeP
, lookAhead
, takeWhileP
, takeWhile
, takeWhile1
, drainWhile
, sliceSepByP
, sliceBeginWith
, sliceSepWith
, escapedSliceSepBy
, escapedFrameBy
, wordBy
, groupBy
, groupByRolling
, groupByRollingEither
, eqBy
, serialWith
, split_
, teeWith
, teeWithFst
, teeWithMin
, deintercalate
, alt
, shortest
, longest
, concatSequence
, concatMap
, count
, countBetween
, manyP
, many
, some
, manyTillP
, manyTill
, manyThen
, roundRobin
, choice
, retryMaxTotal
, retryMaxSuccessive
, retry
)
where
import Control.Monad.Catch (MonadCatch, MonadThrow)
import Prelude
hiding (any, all, take, takeWhile, sequence, concatMap, maybe, either)
import Streamly.Internal.Data.Fold.Type (Fold(..))
import Streamly.Internal.Data.Parser.ParserK.Type (Parser)
import qualified Streamly.Internal.Data.Fold.Type as FL
import qualified Streamly.Internal.Data.Parser.ParserD as D
import qualified Streamly.Internal.Data.Parser.ParserK.Type as K
{-# INLINE toFold #-}
toFold :: MonadThrow m => Parser m a b -> Fold m a b
toFold :: Parser m a b -> Fold m a b
toFold Parser m a b
p = Parser m a b -> Fold m a b
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Fold m a b
D.toFold (Parser m a b -> Fold m a b) -> Parser m a b -> Fold m a b
forall a b. (a -> b) -> a -> b
$ Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m a b
p
{-# INLINE fromFold #-}
fromFold :: MonadCatch m => Fold m a b -> Parser m a b
fromFold :: Fold m a b -> Parser m a b
fromFold = Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a b -> Parser m a b)
-> (Fold m a b -> Parser m a b) -> Fold m a b -> Parser m a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Fold m a b -> Parser m a b
forall (m :: * -> *) a b. Monad m => Fold m a b -> Parser m a b
D.fromFold
{-# INLINE [3] fromPure #-}
fromPure :: MonadCatch m => b -> Parser m a b
fromPure :: b -> Parser m a b
fromPure = Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a b -> Parser m a b)
-> (b -> Parser m a b) -> b -> Parser m a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> Parser m a b
forall (m :: * -> *) b a. Monad m => b -> Parser m a b
D.fromPure
{-# RULES "fromPure fallback to CPS" [2]
forall a. K.toParserK (D.fromPure a) = K.fromPure a #-}
{-# INLINE fromEffect #-}
fromEffect :: MonadCatch m => m b -> Parser m a b
fromEffect :: m b -> Parser m a b
fromEffect = m b -> Parser m a b
forall (m :: * -> *) b a. Monad m => m b -> Parser m a b
K.fromEffect
{-# INLINE [3] die #-}
die :: MonadCatch m => String -> Parser m a b
die :: String -> Parser m a b
die = Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a b -> Parser m a b)
-> (String -> Parser m a b) -> String -> Parser m a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Parser m a b
forall (m :: * -> *) a b. MonadThrow m => String -> Parser m a b
D.die
{-# RULES "die fallback to CPS" [2]
forall a. K.toParserK (D.die a) = K.die a #-}
{-# INLINE dieM #-}
dieM :: MonadCatch m => m String -> Parser m a b
dieM :: m String -> Parser m a b
dieM = Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a b -> Parser m a b)
-> (m String -> Parser m a b) -> m String -> Parser m a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m String -> Parser m a b
forall (m :: * -> *) a b. MonadThrow m => m String -> Parser m a b
D.dieM
{-# INLINE peek #-}
peek :: MonadCatch m => Parser m a a
peek :: Parser m a a
peek = Parser m a a -> Parser m a a
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK Parser m a a
forall (m :: * -> *) a. MonadThrow m => Parser m a a
D.peek
{-# INLINE eof #-}
eof :: MonadCatch m => Parser m a ()
eof :: Parser m a ()
eof = Parser m a () -> Parser m a ()
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK Parser m a ()
forall (m :: * -> *) a. Monad m => Parser m a ()
D.eof
{-# INLINE satisfy #-}
satisfy :: MonadCatch m => (a -> Bool) -> Parser m a a
satisfy :: (a -> Bool) -> Parser m a a
satisfy = Parser m a a -> Parser m a a
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a a -> Parser m a a)
-> ((a -> Bool) -> Parser m a a) -> (a -> Bool) -> Parser m a a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Bool) -> Parser m a a
forall (m :: * -> *) a. MonadThrow m => (a -> Bool) -> Parser m a a
D.satisfy
{-# INLINE next #-}
next :: MonadCatch m => Parser m a (Maybe a)
next :: Parser m a (Maybe a)
next = Parser m a (Maybe a) -> Parser m a (Maybe a)
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK Parser m a (Maybe a)
forall (m :: * -> *) a. Monad m => Parser m a (Maybe a)
D.next
{-# INLINE maybe #-}
maybe :: MonadCatch m => (a -> Maybe b) -> Parser m a b
maybe :: (a -> Maybe b) -> Parser m a b
maybe = Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a b -> Parser m a b)
-> ((a -> Maybe b) -> Parser m a b)
-> (a -> Maybe b)
-> Parser m a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Maybe b) -> Parser m a b
forall (m :: * -> *) a b.
MonadThrow m =>
(a -> Maybe b) -> Parser m a b
D.maybe
{-# INLINE either #-}
either :: MonadCatch m => (a -> Either String b) -> Parser m a b
either :: (a -> Either String b) -> Parser m a b
either = Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a b -> Parser m a b)
-> ((a -> Either String b) -> Parser m a b)
-> (a -> Either String b)
-> Parser m a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Either String b) -> Parser m a b
forall (m :: * -> *) a b.
MonadThrow m =>
(a -> Either String b) -> Parser m a b
D.either
{-# INLINE takeBetween #-}
takeBetween :: MonadCatch m =>
Int -> Int -> Fold m a b -> Parser m a b
takeBetween :: Int -> Int -> Fold m a b -> Parser m a b
takeBetween Int
m Int
n = Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a b -> Parser m a b)
-> (Fold m a b -> Parser m a b) -> Fold m a b -> Parser m a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Int -> Fold m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadCatch m =>
Int -> Int -> Fold m a b -> Parser m a b
D.takeBetween Int
m Int
n
{-# INLINE takeEQ #-}
takeEQ :: MonadCatch m => Int -> Fold m a b -> Parser m a b
takeEQ :: Int -> Fold m a b -> Parser m a b
takeEQ Int
n = Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a b -> Parser m a b)
-> (Fold m a b -> Parser m a b) -> Fold m a b -> Parser m a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Fold m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadThrow m =>
Int -> Fold m a b -> Parser m a b
D.takeEQ Int
n
{-# INLINE takeGE #-}
takeGE :: MonadCatch m => Int -> Fold m a b -> Parser m a b
takeGE :: Int -> Fold m a b -> Parser m a b
takeGE Int
n = Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a b -> Parser m a b)
-> (Fold m a b -> Parser m a b) -> Fold m a b -> Parser m a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Fold m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadThrow m =>
Int -> Fold m a b -> Parser m a b
D.takeGE Int
n
{-# INLINE takeWhileP #-}
takeWhileP ::
(a -> Bool) -> Parser m a b -> Parser m a b
takeWhileP :: (a -> Bool) -> Parser m a b -> Parser m a b
takeWhileP a -> Bool
_cond = Parser m a b -> Parser m a b
forall a. HasCallStack => a
undefined
{-# INLINE takeWhile #-}
takeWhile :: MonadCatch m => (a -> Bool) -> Fold m a b -> Parser m a b
takeWhile :: (a -> Bool) -> Fold m a b -> Parser m a b
takeWhile a -> Bool
cond = Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a b -> Parser m a b)
-> (Fold m a b -> Parser m a b) -> Fold m a b -> Parser m a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Bool) -> Fold m a b -> Parser m a b
forall (m :: * -> *) a b.
Monad m =>
(a -> Bool) -> Fold m a b -> Parser m a b
D.takeWhile a -> Bool
cond
{-# INLINE takeWhile1 #-}
takeWhile1 :: MonadCatch m => (a -> Bool) -> Fold m a b -> Parser m a b
takeWhile1 :: (a -> Bool) -> Fold m a b -> Parser m a b
takeWhile1 a -> Bool
cond = Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a b -> Parser m a b)
-> (Fold m a b -> Parser m a b) -> Fold m a b -> Parser m a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Bool) -> Fold m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadThrow m =>
(a -> Bool) -> Fold m a b -> Parser m a b
D.takeWhile1 a -> Bool
cond
{-# INLINE drainWhile #-}
drainWhile :: MonadCatch m => (a -> Bool) -> Parser m a ()
drainWhile :: (a -> Bool) -> Parser m a ()
drainWhile a -> Bool
p = (a -> Bool) -> Fold m a () -> Parser m a ()
forall (m :: * -> *) a b.
MonadCatch m =>
(a -> Bool) -> Fold m a b -> Parser m a b
takeWhile a -> Bool
p Fold m a ()
forall (m :: * -> *) a. Monad m => Fold m a ()
FL.drain
{-# INLINE sliceSepByP #-}
sliceSepByP ::
MonadCatch m =>
(a -> Bool) -> Parser m a b -> Parser m a b
sliceSepByP :: (a -> Bool) -> Parser m a b -> Parser m a b
sliceSepByP a -> Bool
cond = Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a b -> Parser m a b)
-> (Parser m a b -> Parser m a b) -> Parser m a b -> Parser m a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Bool) -> Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadCatch m =>
(a -> Bool) -> Parser m a b -> Parser m a b
D.sliceSepByP a -> Bool
cond (Parser m a b -> Parser m a b)
-> (Parser m a b -> Parser m a b) -> Parser m a b -> Parser m a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK
{-# INLINE sliceSepWith #-}
sliceSepWith ::
(a -> Bool) -> Fold m a b -> Parser m a b
sliceSepWith :: (a -> Bool) -> Fold m a b -> Parser m a b
sliceSepWith a -> Bool
_cond = Fold m a b -> Parser m a b
forall a. HasCallStack => a
undefined
{-# INLINE sliceBeginWith #-}
sliceBeginWith ::
MonadCatch m =>
(a -> Bool) -> Fold m a b -> Parser m a b
sliceBeginWith :: (a -> Bool) -> Fold m a b -> Parser m a b
sliceBeginWith a -> Bool
cond = Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a b -> Parser m a b)
-> (Fold m a b -> Parser m a b) -> Fold m a b -> Parser m a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Bool) -> Fold m a b -> Parser m a b
forall (m :: * -> *) a b.
Monad m =>
(a -> Bool) -> Fold m a b -> Parser m a b
D.sliceBeginWith a -> Bool
cond
{-# INLINE escapedSliceSepBy #-}
escapedSliceSepBy ::
(a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser m a b
escapedSliceSepBy :: (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser m a b
escapedSliceSepBy a -> Bool
_cond a -> Bool
_esc = Fold m a b -> Parser m a b
forall a. HasCallStack => a
undefined
{-# INLINE escapedFrameBy #-}
escapedFrameBy ::
(a -> Bool) -> (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser m a b
escapedFrameBy :: (a -> Bool)
-> (a -> Bool) -> (a -> Bool) -> Fold m a b -> Parser m a b
escapedFrameBy a -> Bool
_begin a -> Bool
_end a -> Bool
_escape Fold m a b
_p = Parser m a b
forall a. HasCallStack => a
undefined
{-# INLINE wordBy #-}
wordBy :: MonadCatch m => (a -> Bool) -> Fold m a b -> Parser m a b
wordBy :: (a -> Bool) -> Fold m a b -> Parser m a b
wordBy a -> Bool
f = Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a b -> Parser m a b)
-> (Fold m a b -> Parser m a b) -> Fold m a b -> Parser m a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Bool) -> Fold m a b -> Parser m a b
forall (m :: * -> *) a b.
Monad m =>
(a -> Bool) -> Fold m a b -> Parser m a b
D.wordBy a -> Bool
f
{-# INLINE groupBy #-}
groupBy :: MonadCatch m => (a -> a -> Bool) -> Fold m a b -> Parser m a b
groupBy :: (a -> a -> Bool) -> Fold m a b -> Parser m a b
groupBy a -> a -> Bool
eq = Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a b -> Parser m a b)
-> (Fold m a b -> Parser m a b) -> Fold m a b -> Parser m a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> a -> Bool) -> Fold m a b -> Parser m a b
forall (m :: * -> *) a b.
Monad m =>
(a -> a -> Bool) -> Fold m a b -> Parser m a b
D.groupBy a -> a -> Bool
eq
{-# INLINE groupByRolling #-}
groupByRolling :: MonadCatch m => (a -> a -> Bool) -> Fold m a b -> Parser m a b
groupByRolling :: (a -> a -> Bool) -> Fold m a b -> Parser m a b
groupByRolling a -> a -> Bool
eq = Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a b -> Parser m a b)
-> (Fold m a b -> Parser m a b) -> Fold m a b -> Parser m a b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> a -> Bool) -> Fold m a b -> Parser m a b
forall (m :: * -> *) a b.
Monad m =>
(a -> a -> Bool) -> Fold m a b -> Parser m a b
D.groupByRolling a -> a -> Bool
eq
{-# INLINE groupByRollingEither #-}
groupByRollingEither :: MonadCatch m =>
(a -> a -> Bool) -> Fold m a b -> Fold m a c -> Parser m a (Either b c)
groupByRollingEither :: (a -> a -> Bool)
-> Fold m a b -> Fold m a c -> Parser m a (Either b c)
groupByRollingEither a -> a -> Bool
eq Fold m a b
f1 = Parser m a (Either b c) -> Parser m a (Either b c)
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a (Either b c) -> Parser m a (Either b c))
-> (Fold m a c -> Parser m a (Either b c))
-> Fold m a c
-> Parser m a (Either b c)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> a -> Bool)
-> Fold m a b -> Fold m a c -> Parser m a (Either b c)
forall (m :: * -> *) a b c.
MonadCatch m =>
(a -> a -> Bool)
-> Fold m a b -> Fold m a c -> Parser m a (Either b c)
D.groupByRollingEither a -> a -> Bool
eq Fold m a b
f1
{-# INLINE eqBy #-}
eqBy :: MonadCatch m => (a -> a -> Bool) -> [a] -> Parser m a ()
eqBy :: (a -> a -> Bool) -> [a] -> Parser m a ()
eqBy a -> a -> Bool
cmp = Parser m a () -> Parser m a ()
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a () -> Parser m a ())
-> ([a] -> Parser m a ()) -> [a] -> Parser m a ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> a -> Bool) -> [a] -> Parser m a ()
forall (m :: * -> *) a.
MonadThrow m =>
(a -> a -> Bool) -> [a] -> Parser m a ()
D.eqBy a -> a -> Bool
cmp
{-# INLINE serialWith #-}
serialWith :: MonadCatch m
=> (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
serialWith :: (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
serialWith a -> b -> c
f Parser m x a
p1 Parser m x b
p2 =
Parser m x c -> Parser m x c
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m x c -> Parser m x c) -> Parser m x c -> Parser m x c
forall a b. (a -> b) -> a -> b
$ (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
forall (m :: * -> *) a b c x.
MonadThrow m =>
(a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
D.serialWith a -> b -> c
f (Parser m x a -> Parser m x a
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m x a
p1) (Parser m x b -> Parser m x b
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m x b
p2)
{-# INLINE split_ #-}
split_ :: MonadCatch m => Parser m x a -> Parser m x b -> Parser m x b
split_ :: Parser m x a -> Parser m x b -> Parser m x b
split_ Parser m x a
p1 Parser m x b
p2 = Parser m x b -> Parser m x b
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m x b -> Parser m x b) -> Parser m x b -> Parser m x b
forall a b. (a -> b) -> a -> b
$ Parser m x a -> Parser m x b -> Parser m x b
forall (m :: * -> *) x a b.
MonadThrow m =>
Parser m x a -> Parser m x b -> Parser m x b
D.split_ (Parser m x a -> Parser m x a
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m x a
p1) (Parser m x b -> Parser m x b
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m x b
p2)
{-# INLINE teeWith #-}
teeWith :: MonadCatch m
=> (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
teeWith :: (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
teeWith a -> b -> c
f Parser m x a
p1 Parser m x b
p2 =
Parser m x c -> Parser m x c
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m x c -> Parser m x c) -> Parser m x c -> Parser m x c
forall a b. (a -> b) -> a -> b
$ (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
forall (m :: * -> *) a b c x.
Monad m =>
(a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
D.teeWith a -> b -> c
f (Parser m x a -> Parser m x a
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m x a
p1) (Parser m x b -> Parser m x b
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m x b
p2)
{-# INLINE teeWithFst #-}
teeWithFst :: MonadCatch m
=> (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
teeWithFst :: (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
teeWithFst a -> b -> c
f Parser m x a
p1 Parser m x b
p2 =
Parser m x c -> Parser m x c
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m x c -> Parser m x c) -> Parser m x c -> Parser m x c
forall a b. (a -> b) -> a -> b
$ (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
forall (m :: * -> *) a b c x.
Monad m =>
(a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
D.teeWithFst a -> b -> c
f (Parser m x a -> Parser m x a
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m x a
p1) (Parser m x b -> Parser m x b
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m x b
p2)
{-# INLINE teeWithMin #-}
teeWithMin :: MonadCatch m
=> (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
teeWithMin :: (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
teeWithMin a -> b -> c
f Parser m x a
p1 Parser m x b
p2 =
Parser m x c -> Parser m x c
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m x c -> Parser m x c) -> Parser m x c -> Parser m x c
forall a b. (a -> b) -> a -> b
$ (a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
forall a b c (m :: * -> *) x.
(a -> b -> c) -> Parser m x a -> Parser m x b -> Parser m x c
D.teeWithMin a -> b -> c
f (Parser m x a -> Parser m x a
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m x a
p1) (Parser m x b -> Parser m x b
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m x b
p2)
{-# INLINE alt #-}
alt :: MonadCatch m => Parser m x a -> Parser m x a -> Parser m x a
alt :: Parser m x a -> Parser m x a -> Parser m x a
alt Parser m x a
p1 Parser m x a
p2 = Parser m x a -> Parser m x a
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m x a -> Parser m x a) -> Parser m x a -> Parser m x a
forall a b. (a -> b) -> a -> b
$ Parser m x a -> Parser m x a -> Parser m x a
forall (m :: * -> *) x a.
Monad m =>
Parser m x a -> Parser m x a -> Parser m x a
D.alt (Parser m x a -> Parser m x a
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m x a
p1) (Parser m x a -> Parser m x a
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m x a
p2)
{-# INLINE shortest #-}
shortest :: MonadCatch m
=> Parser m x a -> Parser m x a -> Parser m x a
shortest :: Parser m x a -> Parser m x a -> Parser m x a
shortest Parser m x a
p1 Parser m x a
p2 = Parser m x a -> Parser m x a
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m x a -> Parser m x a) -> Parser m x a -> Parser m x a
forall a b. (a -> b) -> a -> b
$ Parser m x a -> Parser m x a -> Parser m x a
forall (m :: * -> *) x a.
Monad m =>
Parser m x a -> Parser m x a -> Parser m x a
D.shortest (Parser m x a -> Parser m x a
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m x a
p1) (Parser m x a -> Parser m x a
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m x a
p2)
{-# INLINE longest #-}
longest :: MonadCatch m
=> Parser m x a -> Parser m x a -> Parser m x a
longest :: Parser m x a -> Parser m x a -> Parser m x a
longest Parser m x a
p1 Parser m x a
p2 = Parser m x a -> Parser m x a
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m x a -> Parser m x a) -> Parser m x a -> Parser m x a
forall a b. (a -> b) -> a -> b
$ Parser m x a -> Parser m x a -> Parser m x a
forall (m :: * -> *) x a.
MonadCatch m =>
Parser m x a -> Parser m x a -> Parser m x a
D.longest (Parser m x a -> Parser m x a
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m x a
p1) (Parser m x a -> Parser m x a
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m x a
p2)
{-# INLINE lookAhead #-}
lookAhead :: MonadCatch m => Parser m a b -> Parser m a b
lookAhead :: Parser m a b -> Parser m a b
lookAhead Parser m a b
p = Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a b -> Parser m a b) -> Parser m a b -> Parser m a b
forall a b. (a -> b) -> a -> b
$ Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
D.lookAhead (Parser m a b -> Parser m a b) -> Parser m a b -> Parser m a b
forall a b. (a -> b) -> a -> b
$ Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m a b
p
{-# INLINE takeP #-}
takeP :: MonadCatch m => Int -> Parser m a b -> Parser m a b
takeP :: Int -> Parser m a b -> Parser m a b
takeP Int
i Parser m a b
p = Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a b -> Parser m a b) -> Parser m a b -> Parser m a b
forall a b. (a -> b) -> a -> b
$ Int -> Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
Monad m =>
Int -> Parser m a b -> Parser m a b
D.takeP Int
i (Parser m a b -> Parser m a b) -> Parser m a b -> Parser m a b
forall a b. (a -> b) -> a -> b
$ Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m a b
p
{-# INLINE deintercalate #-}
deintercalate ::
Fold m a y -> Parser m x a
-> Fold m b z -> Parser m x b
-> Parser m x (y, z)
deintercalate :: Fold m a y
-> Parser m x a -> Fold m b z -> Parser m x b -> Parser m x (y, z)
deintercalate = Fold m a y
-> Parser m x a -> Fold m b z -> Parser m x b -> Parser m x (y, z)
forall a. HasCallStack => a
undefined
{-# INLINE concatSequence #-}
concatSequence ::
Fold m b c -> t (Parser m a b) -> Parser m a c
concatSequence :: Fold m b c -> t (Parser m a b) -> Parser m a c
concatSequence Fold m b c
_f t (Parser m a b)
_p = Parser m a c
forall a. HasCallStack => a
undefined
{-# INLINE concatMap #-}
concatMap :: MonadCatch m
=> (b -> Parser m a c) -> Parser m a b -> Parser m a c
concatMap :: (b -> Parser m a c) -> Parser m a b -> Parser m a c
concatMap b -> Parser m a c
f Parser m a b
p = Parser m a c -> Parser m a c
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a c -> Parser m a c) -> Parser m a c -> Parser m a c
forall a b. (a -> b) -> a -> b
$ (b -> Parser m a c) -> Parser m a b -> Parser m a c
forall (m :: * -> *) b a c.
MonadThrow m =>
(b -> Parser m a c) -> Parser m a b -> Parser m a c
D.concatMap (Parser m a c -> Parser m a c
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK (Parser m a c -> Parser m a c)
-> (b -> Parser m a c) -> b -> Parser m a c
forall b c a. (b -> c) -> (a -> b) -> a -> c
. b -> Parser m a c
f) (Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m a b
p)
{-# INLINE choice #-}
choice ::
(Functor t, Foldable t, MonadCatch m) => t (Parser m a b) -> Parser m a b
choice :: t (Parser m a b) -> Parser m a b
choice t (Parser m a b)
ps = Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a b -> Parser m a b) -> Parser m a b -> Parser m a b
forall a b. (a -> b) -> a -> b
$ t (Parser m a b) -> Parser m a b
forall (m :: * -> *) (t :: * -> *) a b.
(MonadCatch m, Foldable t) =>
t (Parser m a b) -> Parser m a b
D.choice (t (Parser m a b) -> Parser m a b)
-> t (Parser m a b) -> Parser m a b
forall a b. (a -> b) -> a -> b
$ Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK (Parser m a b -> Parser m a b)
-> t (Parser m a b) -> t (Parser m a b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> t (Parser m a b)
ps
{-# INLINE manyP #-}
manyP ::
Parser m a b -> Parser m b c -> Parser m a c
manyP :: Parser m a b -> Parser m b c -> Parser m a c
manyP Parser m a b
_p Parser m b c
_f = Parser m a c
forall a. HasCallStack => a
undefined
{-# INLINE many #-}
many :: MonadCatch m => Parser m a b -> Fold m b c -> Parser m a c
many :: Parser m a b -> Fold m b c -> Parser m a c
many Parser m a b
p Fold m b c
f = Parser m a c -> Parser m a c
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a c -> Parser m a c) -> Parser m a c -> Parser m a c
forall a b. (a -> b) -> a -> b
$ Parser m a b -> Fold m b c -> Parser m a c
forall (m :: * -> *) a b c.
MonadCatch m =>
Parser m a b -> Fold m b c -> Parser m a c
D.many (Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m a b
p) Fold m b c
f
{-# INLINE some #-}
some :: MonadCatch m => Parser m a b -> Fold m b c -> Parser m a c
some :: Parser m a b -> Fold m b c -> Parser m a c
some Parser m a b
p Fold m b c
f = Parser m a c -> Parser m a c
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a c -> Parser m a c) -> Parser m a c -> Parser m a c
forall a b. (a -> b) -> a -> b
$ Parser m a b -> Fold m b c -> Parser m a c
forall (m :: * -> *) a b c.
MonadCatch m =>
Parser m a b -> Fold m b c -> Parser m a c
D.some (Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m a b
p) Fold m b c
f
{-# INLINE countBetween #-}
countBetween ::
Int -> Int -> Parser m a b -> Fold m b c -> Parser m a c
countBetween :: Int -> Int -> Parser m a b -> Fold m b c -> Parser m a c
countBetween Int
_m Int
_n Parser m a b
_p = Fold m b c -> Parser m a c
forall a. HasCallStack => a
undefined
{-# INLINE count #-}
count ::
Int -> Parser m a b -> Fold m b c -> Parser m a c
count :: Int -> Parser m a b -> Fold m b c -> Parser m a c
count Int
n = Int -> Int -> Parser m a b -> Fold m b c -> Parser m a c
forall (m :: * -> *) a b c.
Int -> Int -> Parser m a b -> Fold m b c -> Parser m a c
countBetween Int
n Int
n
{-# INLINE manyTillP #-}
manyTillP ::
Parser m a b -> Parser m a x -> Parser m b c -> Parser m a c
manyTillP :: Parser m a b -> Parser m a x -> Parser m b c -> Parser m a c
manyTillP Parser m a b
_p1 Parser m a x
_p2 Parser m b c
_f = Parser m a c
forall a. HasCallStack => a
undefined
{-# INLINE manyTill #-}
manyTill :: MonadCatch m
=> Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
manyTill :: Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
manyTill Parser m a b
p1 Parser m a x
p2 Fold m b c
f =
Parser m a c -> Parser m a c
forall (m :: * -> *) a b.
MonadCatch m =>
Parser m a b -> Parser m a b
K.toParserK (Parser m a c -> Parser m a c) -> Parser m a c -> Parser m a c
forall a b. (a -> b) -> a -> b
$ Fold m b c -> Parser m a b -> Parser m a x -> Parser m a c
forall (m :: * -> *) b c a x.
MonadCatch m =>
Fold m b c -> Parser m a b -> Parser m a x -> Parser m a c
D.manyTill Fold m b c
f (Parser m a b -> Parser m a b
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m a b
p1) (Parser m a x -> Parser m a x
forall (m :: * -> *) a b.
MonadThrow m =>
Parser m a b -> Parser m a b
K.fromParserK Parser m a x
p2)
{-# INLINE manyThen #-}
manyThen ::
Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
manyThen :: Parser m a b -> Parser m a x -> Fold m b c -> Parser m a c
manyThen Parser m a b
_parser Parser m a x
_recover Fold m b c
_f = Parser m a c
forall a. HasCallStack => a
undefined
{-# INLINE roundRobin #-}
roundRobin ::
t (Parser m a b) -> Fold m b c -> Parser m a c
roundRobin :: t (Parser m a b) -> Fold m b c -> Parser m a c
roundRobin t (Parser m a b)
_ps Fold m b c
_f = Parser m a c
forall a. HasCallStack => a
undefined
{-# INLINE retryMaxTotal #-}
retryMaxTotal ::
Int -> Parser m a b -> Fold m b c -> Parser m a c
retryMaxTotal :: Int -> Parser m a b -> Fold m b c -> Parser m a c
retryMaxTotal Int
_n Parser m a b
_p Fold m b c
_f = Parser m a c
forall a. HasCallStack => a
undefined
{-# INLINE retryMaxSuccessive #-}
retryMaxSuccessive ::
Int -> Parser m a b -> Fold m b c -> Parser m a c
retryMaxSuccessive :: Int -> Parser m a b -> Fold m b c -> Parser m a c
retryMaxSuccessive Int
_n Parser m a b
_p Fold m b c
_f = Parser m a c
forall a. HasCallStack => a
undefined
{-# INLINE retry #-}
retry ::
Parser m a b -> Parser m a b
retry :: Parser m a b -> Parser m a b
retry Parser m a b
_p = Parser m a b
forall a. HasCallStack => a
undefined