    {-# LANGUAGE FlexibleContexts #-}
    {-# LANGUAGE OverloadedStrings #-}
    {-# LANGUAGE TypeFamilies #-}

    module Data.JSONPath.Parser (jsonPathElement, jsonPath) where

    import qualified Data.Char as Char
    import Data.Functor
    import Data.Functor.Identity
    import Data.JSONPath.Types
    import Data.Text (Text)
    import qualified Data.Text as Text
    import Data.Void (Void)
    import Text.Megaparsec as P
    import Text.Megaparsec.Char (char, space, string)
    import qualified Text.Megaparsec.Char.Lexer as L

    type Parser = P.ParsecT Void Text Identity

    jsonPath :: Parser a -> Parser [JSONPathElement]
    jsonPath :: forall a. Parser a -> Parser [JSONPathElement]
    jsonPath Parser a
    endParser = do
      _ <- ParsecT Void Text Identity Char
    -> ParsecT Void Text Identity (Maybe Char)
    forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
    optional (ParsecT Void Text Identity Char
     -> ParsecT Void Text Identity (Maybe Char))
    -> ParsecT Void Text Identity Char
    -> ParsecT Void Text Identity (Maybe Char)
    forall a b. (a -> b) -> a -> b
    $ Token Text -> ParsecT Void Text Identity (Token Text)
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    Token s -> m (Token s)
    char Char
    Token Text
    '$'
      manyTill jsonPathElement (hidden $ lookAhead endParser)

    jsonPathElement :: Parser JSONPathElement
    jsonPathElement :: ParsecT Void Text Identity JSONPathElement
    jsonPathElement =
      ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    ignoreSurroundingSpace (ParsecT Void Text Identity JSONPathElement
     -> ParsecT Void Text Identity JSONPathElement)
    -> ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    forall a b. (a -> b) -> a -> b
    $
        ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try ParsecT Void Text Identity JSONPathElement
    anyChild
          ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try ParsecT Void Text Identity JSONPathElement
    keyChild
          ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try ParsecT Void Text Identity JSONPathElement
    slice
          ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try ParsecT Void Text Identity JSONPathElement
    indexChild
          ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try ParsecT Void Text Identity JSONPathElement
    union
          ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try ParsecT Void Text Identity JSONPathElement
    filterParser
          ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try ParsecT Void Text Identity JSONPathElement
    search
          ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> ParsecT Void Text Identity JSONPathElement
    searchBeginningWithSlice

    indexChild :: Parser JSONPathElement
    indexChild :: ParsecT Void Text Identity JSONPathElement
    indexChild = Int -> JSONPathElement
    IndexChild (Int -> JSONPathElement)
    -> ParsecT Void Text Identity Int
    -> ParsecT Void Text Identity JSONPathElement
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity Int -> ParsecT Void Text Identity Int
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    inSqBr ParsecT Void Text Identity Int
    indexChildWithoutBrackets

    indexChildWithoutBrackets :: Parser Int
    indexChildWithoutBrackets :: ParsecT Void Text Identity Int
    indexChildWithoutBrackets = ParsecT Void Text Identity Int -> ParsecT Void Text Identity Int
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    ignoreSurroundingSpace (ParsecT Void Text Identity Int -> ParsecT Void Text Identity Int)
    -> ParsecT Void Text Identity Int -> ParsecT Void Text Identity Int
    forall a b. (a -> b) -> a -> b
    $ ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity Int -> ParsecT Void Text Identity Int
    forall e s (m :: * -> *) a.
    (MonadParsec e s m, Token s ~ Char, Num a) =>
    m () -> m a -> m a
    L.signed ParsecT Void Text Identity ()
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    m ()
    space ParsecT Void Text Identity Int
    forall e s (m :: * -> *) a.
    (MonadParsec e s m, Token s ~ Char, Num a) =>
    m a
    L.decimal

    slice :: Parser JSONPathElement
    slice :: ParsecT Void Text Identity JSONPathElement
    slice =
      (Maybe Int -> Maybe Int -> Maybe Int -> JSONPathElement)
    -> (Maybe Int, Maybe Int, Maybe Int) -> JSONPathElement
    forall a b c d. (a -> b -> c -> d) -> (a, b, c) -> d
    uncurry3 Maybe Int -> Maybe Int -> Maybe Int -> JSONPathElement
    Slice
        ((Maybe Int, Maybe Int, Maybe Int) -> JSONPathElement)
    -> ParsecT Void Text Identity (Maybe Int, Maybe Int, Maybe Int)
    -> ParsecT Void Text Identity JSONPathElement
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity (Maybe Int, Maybe Int, Maybe Int)
    -> ParsecT Void Text Identity (Maybe Int, Maybe Int, Maybe Int)
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    inSqBr ParsecT Void Text Identity (Maybe Int, Maybe Int, Maybe Int)
    sliceWithoutBrackets

    sliceWithoutBrackets :: Parser (Maybe Int, Maybe Int, Maybe Int)
    sliceWithoutBrackets :: ParsecT Void Text Identity (Maybe Int, Maybe Int, Maybe Int)
    sliceWithoutBrackets = do
      (,,)
        (Maybe Int
     -> Maybe Int -> Maybe Int -> (Maybe Int, Maybe Int, Maybe Int))
    -> ParsecT Void Text Identity (Maybe Int)
    -> ParsecT
         Void
         Text
         Identity
         (Maybe Int -> Maybe Int -> (Maybe Int, Maybe Int, Maybe Int))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity (Maybe Int)
    parseStart
        ParsecT
      Void
      Text
      Identity
      (Maybe Int -> Maybe Int -> (Maybe Int, Maybe Int, Maybe Int))
    -> ParsecT Void Text Identity (Maybe Int)
    -> ParsecT
         Void Text Identity (Maybe Int -> (Maybe Int, Maybe Int, Maybe Int))
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity (Maybe Int)
    parseEnd
        ParsecT
      Void Text Identity (Maybe Int -> (Maybe Int, Maybe Int, Maybe Int))
    -> ParsecT Void Text Identity (Maybe Int)
    -> ParsecT Void Text Identity (Maybe Int, Maybe Int, Maybe Int)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity (Maybe Int)
    parseStep
      where
        parseStart :: Parser (Maybe Int)
        parseStart :: ParsecT Void Text Identity (Maybe Int)
    parseStart =
          ParsecT Void Text Identity (Maybe Int)
    -> ParsecT Void Text Identity (Maybe Int)
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    ignoreSurroundingSpace (ParsecT Void Text Identity Int
    -> ParsecT Void Text Identity (Maybe Int)
    forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
    optional (ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity Int -> ParsecT Void Text Identity Int
    forall e s (m :: * -> *) a.
    (MonadParsec e s m, Token s ~ Char, Num a) =>
    m () -> m a -> m a
    L.signed ParsecT Void Text Identity ()
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    m ()
    space ParsecT Void Text Identity Int
    forall e s (m :: * -> *) a.
    (MonadParsec e s m, Token s ~ Char, Num a) =>
    m a
    L.decimal))
            ParsecT Void Text Identity (Maybe Int)
    -> ParsecT Void Text Identity Char
    -> ParsecT Void Text Identity (Maybe Int)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Token Text -> ParsecT Void Text Identity (Token Text)
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    Token s -> m (Token s)
    char Char
    Token Text
    ':'

        parseEnd :: ParsecT Void Text Identity (Maybe Int)
    parseEnd =
          ParsecT Void Text Identity (Maybe Int)
    -> ParsecT Void Text Identity (Maybe Int)
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    ignoreSurroundingSpace (ParsecT Void Text Identity (Maybe Int)
     -> ParsecT Void Text Identity (Maybe Int))
    -> ParsecT Void Text Identity (Maybe Int)
    -> ParsecT Void Text Identity (Maybe Int)
    forall a b. (a -> b) -> a -> b
    $ ParsecT Void Text Identity Int
    -> ParsecT Void Text Identity (Maybe Int)
    forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
    optional (ParsecT Void Text Identity Int
     -> ParsecT Void Text Identity (Maybe Int))
    -> ParsecT Void Text Identity Int
    -> ParsecT Void Text Identity (Maybe Int)
    forall a b. (a -> b) -> a -> b
    $ ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity Int -> ParsecT Void Text Identity Int
    forall e s (m :: * -> *) a.
    (MonadParsec e s m, Token s ~ Char, Num a) =>
    m () -> m a -> m a
    L.signed ParsecT Void Text Identity ()
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    m ()
    space ParsecT Void Text Identity Int
    forall e s (m :: * -> *) a.
    (MonadParsec e s m, Token s ~ Char, Num a) =>
    m a
    L.decimal

        parseStep :: ParsecT Void Text Identity (Maybe Int)
    parseStep =
          ParsecT Void Text Identity Char
    -> ParsecT Void Text Identity (Maybe Char)
    forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
    optional (Token Text -> ParsecT Void Text Identity (Token Text)
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    Token s -> m (Token s)
    char Char
    Token Text
    ':')
            ParsecT Void Text Identity (Maybe Char)
    -> ParsecT Void Text Identity (Maybe Int)
    -> ParsecT Void Text Identity (Maybe Int)
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Void Text Identity (Maybe Int)
    -> ParsecT Void Text Identity (Maybe Int)
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    ignoreSurroundingSpace (ParsecT Void Text Identity Int
    -> ParsecT Void Text Identity (Maybe Int)
    forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
    optional (ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity Int -> ParsecT Void Text Identity Int
    forall e s (m :: * -> *) a.
    (MonadParsec e s m, Token s ~ Char, Num a) =>
    m () -> m a -> m a
    L.signed ParsecT Void Text Identity ()
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    m ()
    space ParsecT Void Text Identity Int
    forall e s (m :: * -> *) a.
    (MonadParsec e s m, Token s ~ Char, Num a) =>
    m a
    L.decimal))

    keyChild :: Parser JSONPathElement
    keyChild :: ParsecT Void Text Identity JSONPathElement
    keyChild = Text -> JSONPathElement
    KeyChild (Text -> JSONPathElement)
    -> ParsecT Void Text Identity Text
    -> ParsecT Void Text Identity JSONPathElement
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (ParsecT Void Text Identity Text -> ParsecT Void Text Identity Text
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try ParsecT Void Text Identity Text
    sqBrKeyChild ParsecT Void Text Identity Text
    -> ParsecT Void Text Identity Text
    -> ParsecT Void Text Identity Text
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> ParsecT Void Text Identity Text
    dotKeyChild)

    sqBrKeyChild :: Parser Text
    sqBrKeyChild :: ParsecT Void Text Identity Text
    sqBrKeyChild =
      ParsecT Void Text Identity Text -> ParsecT Void Text Identity Text
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    inSqBr (ParsecT Void Text Identity Text
     -> ParsecT Void Text Identity Text)
    -> ParsecT Void Text Identity Text
    -> ParsecT Void Text Identity Text
    forall a b. (a -> b) -> a -> b
    $ ParsecT Void Text Identity Text -> ParsecT Void Text Identity Text
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    ignoreSurroundingSpace ParsecT Void Text Identity Text
    quotedString

    dotKeyChild :: Parser Text
    dotKeyChild :: ParsecT Void Text Identity Text
    dotKeyChild = Token Text -> ParsecT Void Text Identity (Token Text)
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    Token s -> m (Token s)
    char Char
    Token Text
    '.' ParsecT Void Text Identity Char
    -> ParsecT Void Text Identity Text
    -> ParsecT Void Text Identity Text
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Maybe String
    -> (Token Text -> Bool) -> ParsecT Void Text Identity (Tokens Text)
    forall e s (m :: * -> *).
    MonadParsec e s m =>
    Maybe String -> (Token s -> Bool) -> m (Tokens s)
    takeWhile1P Maybe String
    forall a. Maybe a
    Nothing (\Token Text
    c -> Char -> Bool
    Char.isAlphaNum Char
    Token Text
    c Bool -> Bool -> Bool
    || Char
    Token Text
    c Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    == Char
    '-' Bool -> Bool -> Bool
    || Char
    Token Text
    c Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    == Char
    '_')

    anyChild :: Parser JSONPathElement
    anyChild :: ParsecT Void Text Identity JSONPathElement
    anyChild = ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    ignoreSurroundingSpace (ParsecT Void Text Identity JSONPathElement
     -> ParsecT Void Text Identity JSONPathElement)
    -> ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    forall a b. (a -> b) -> a -> b
    $ JSONPathElement
    AnyChild JSONPathElement
    -> ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity JSONPathElement
    forall a b.
    a -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ (ParsecT Void Text Identity (Tokens Text)
    -> ParsecT Void Text Identity ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void (Tokens Text -> ParsecT Void Text Identity (Tokens Text)
    forall e s (m :: * -> *).
    MonadParsec e s m =>
    Tokens s -> m (Tokens s)
    string Tokens Text
    ".*") ParsecT Void Text Identity ()
    -> ParsecT Void Text Identity () -> ParsecT Void Text Identity ()
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> ParsecT Void Text Identity Char -> ParsecT Void Text Identity ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void (ParsecT Void Text Identity Char -> ParsecT Void Text Identity Char
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    inSqBr (Token Text -> ParsecT Void Text Identity (Token Text)
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    Token s -> m (Token s)
    char Char
    Token Text
    '*')))

    union :: Parser JSONPathElement
    union :: ParsecT Void Text Identity JSONPathElement
    union =
      ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    inSqBr (ParsecT Void Text Identity JSONPathElement
     -> ParsecT Void Text Identity JSONPathElement)
    -> ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    forall a b. (a -> b) -> a -> b
    $
        [UnionElement] -> JSONPathElement
    Union ([UnionElement] -> JSONPathElement)
    -> ParsecT Void Text Identity [UnionElement]
    -> ParsecT Void Text Identity JSONPathElement
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> do
          firstElement <- Parser UnionElement
    unionElement
          restElements <- some (char ',' *> unionElement)
          pure (firstElement : restElements)

    unionElement :: Parser UnionElement
    unionElement :: Parser UnionElement
    unionElement =
      Parser UnionElement -> Parser UnionElement
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try ((Maybe Int -> Maybe Int -> Maybe Int -> UnionElement)
    -> (Maybe Int, Maybe Int, Maybe Int) -> UnionElement
    forall a b c d. (a -> b -> c -> d) -> (a, b, c) -> d
    uncurry3 Maybe Int -> Maybe Int -> Maybe Int -> UnionElement
    UESlice ((Maybe Int, Maybe Int, Maybe Int) -> UnionElement)
    -> ParsecT Void Text Identity (Maybe Int, Maybe Int, Maybe Int)
    -> Parser UnionElement
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity (Maybe Int, Maybe Int, Maybe Int)
    sliceWithoutBrackets)
        Parser UnionElement -> Parser UnionElement -> Parser UnionElement
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> Parser UnionElement -> Parser UnionElement
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try (Int -> UnionElement
    UEIndexChild (Int -> UnionElement)
    -> ParsecT Void Text Identity Int -> Parser UnionElement
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity Int
    indexChildWithoutBrackets)
        Parser UnionElement -> Parser UnionElement -> Parser UnionElement
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> Text -> UnionElement
    UEKeyChild (Text -> UnionElement)
    -> ParsecT Void Text Identity Text -> Parser UnionElement
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity Text -> ParsecT Void Text Identity Text
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    ignoreSurroundingSpace ParsecT Void Text Identity Text
    quotedString

    filterParser :: Parser JSONPathElement
    filterParser :: ParsecT Void Text Identity JSONPathElement
    filterParser = ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    inSqBr (ParsecT Void Text Identity JSONPathElement
     -> ParsecT Void Text Identity JSONPathElement)
    -> ParsecT Void Text Identity JSONPathElement
    -> ParsecT Void Text Identity JSONPathElement
    forall a b. (a -> b) -> a -> b
    $ do
      _ <- ParsecT Void Text Identity Char -> ParsecT Void Text Identity Char
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    ignoreSurroundingSpace (ParsecT Void Text Identity Char
     -> ParsecT Void Text Identity Char)
    -> ParsecT Void Text Identity Char
    -> ParsecT Void Text Identity Char
    forall a b. (a -> b) -> a -> b
    $ Token Text -> ParsecT Void Text Identity (Token Text)
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    Token s -> m (Token s)
    char Char
    Token Text
    '?'
      Filter <$> filterExpr (ignoreSurroundingSpace (char ']'))

    filterExpr :: Parser a -> Parser FilterExpr
    filterExpr :: forall a. Parser a -> ParsecT Void Text Identity FilterExpr
    filterExpr Parser a
    endParser =
      ParsecT Void Text Identity FilterExpr
    -> ParsecT Void Text Identity FilterExpr
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try (Parser a -> ParsecT Void Text Identity FilterExpr
    forall a. Parser a -> ParsecT Void Text Identity FilterExpr
    orFilterExpr Parser a
    endParser)
        ParsecT Void Text Identity FilterExpr
    -> ParsecT Void Text Identity FilterExpr
    -> ParsecT Void Text Identity FilterExpr
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> ParsecT Void Text Identity FilterExpr
    -> ParsecT Void Text Identity FilterExpr
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try (Parser a -> ParsecT Void Text Identity FilterExpr
    forall a. Parser a -> ParsecT Void Text Identity FilterExpr
    andFilterExpr Parser a
    endParser)
        ParsecT Void Text Identity FilterExpr
    -> ParsecT Void Text Identity FilterExpr
    -> ParsecT Void Text Identity FilterExpr
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> Parser a -> ParsecT Void Text Identity FilterExpr
    forall a. Parser a -> ParsecT Void Text Identity FilterExpr
    basicFilterExpr Parser a
    endParser

    basicFilterExpr :: Parser a -> Parser FilterExpr
    basicFilterExpr :: forall a. Parser a -> ParsecT Void Text Identity FilterExpr
    basicFilterExpr Parser a
    endParser = do
      maybeNot <- ParsecT Void Text Identity Char
    -> ParsecT Void Text Identity (Maybe Char)
    forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
    optional (Token Text -> ParsecT Void Text Identity (Token Text)
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    Token s -> m (Token s)
    char Char
    Token Text
    '!')
      expr <-
        try (comparisionFilterExpr endParser)
          <|> try (existsFilterExpr endParser)
          <|> (inParens (filterExpr closingParen) <* lookAhead endParser)
      case maybeNot of
        Maybe Char
    Nothing -> FilterExpr -> ParsecT Void Text Identity FilterExpr
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure FilterExpr
    expr
        Just Char
    _ -> FilterExpr -> ParsecT Void Text Identity FilterExpr
    forall a. a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure (FilterExpr -> ParsecT Void Text Identity FilterExpr)
    -> FilterExpr -> ParsecT Void Text Identity FilterExpr
    forall a b. (a -> b) -> a -> b
    $ FilterExpr -> FilterExpr
    Not FilterExpr
    expr

    comparisionFilterExpr :: Parser a -> Parser FilterExpr
    comparisionFilterExpr :: forall a. Parser a -> ParsecT Void Text Identity FilterExpr
    comparisionFilterExpr Parser a
    endParser = do
      expr <-
        Comparable -> Condition -> Comparable -> FilterExpr
    ComparisonExpr
          (Comparable -> Condition -> Comparable -> FilterExpr)
    -> ParsecT Void Text Identity Comparable
    -> ParsecT
         Void Text Identity (Condition -> Comparable -> FilterExpr)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser Condition -> ParsecT Void Text Identity Comparable
    forall a. Parser a -> ParsecT Void Text Identity Comparable
    comparable Parser Condition
    condition
          ParsecT Void Text Identity (Condition -> Comparable -> FilterExpr)
    -> Parser Condition
    -> ParsecT Void Text Identity (Comparable -> FilterExpr)
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser Condition
    condition
          ParsecT Void Text Identity (Comparable -> FilterExpr)
    -> ParsecT Void Text Identity Comparable
    -> ParsecT Void Text Identity FilterExpr
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser a -> ParsecT Void Text Identity Comparable
    forall a. Parser a -> ParsecT Void Text Identity Comparable
    comparable Parser a
    endParser
      _ <- lookAhead endParser
      pure expr

    existsFilterExpr :: Parser a -> Parser FilterExpr
    existsFilterExpr :: forall a. Parser a -> ParsecT Void Text Identity FilterExpr
    existsFilterExpr Parser a
    endParser =
      SingularPath -> FilterExpr
    ExistsExpr (SingularPath -> FilterExpr)
    -> ParsecT Void Text Identity SingularPath
    -> ParsecT Void Text Identity FilterExpr
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser a -> ParsecT Void Text Identity SingularPath
    forall a. Parser a -> ParsecT Void Text Identity SingularPath
    singularPath Parser a
    endParser

    singularPath :: Parser a -> Parser SingularPath
    singularPath :: forall a. Parser a -> ParsecT Void Text Identity SingularPath
    singularPath Parser a
    endParser =
      BeginningPoint -> [SingularPathElement] -> SingularPath
    SingularPath
        (BeginningPoint -> [SingularPathElement] -> SingularPath)
    -> ParsecT Void Text Identity BeginningPoint
    -> ParsecT
         Void Text Identity ([SingularPathElement] -> SingularPath)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity BeginningPoint
    beginningPoint
        ParsecT Void Text Identity ([SingularPathElement] -> SingularPath)
    -> ParsecT Void Text Identity [SingularPathElement]
    -> ParsecT Void Text Identity SingularPath
    forall a b.
    ParsecT Void Text Identity (a -> b)
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Void Text Identity SingularPathElement
    -> Parser a -> ParsecT Void Text Identity [SingularPathElement]
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    manyTill ParsecT Void Text Identity SingularPathElement
    singularPathElement (Parser a -> Parser a
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    lookAhead Parser a
    endParser)

    singularPathElement :: Parser SingularPathElement
    singularPathElement :: ParsecT Void Text Identity SingularPathElement
    singularPathElement =
      (Text -> SingularPathElement
    Key (Text -> SingularPathElement)
    -> ParsecT Void Text Identity Text
    -> ParsecT Void Text Identity SingularPathElement
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity Text -> ParsecT Void Text Identity Text
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try ParsecT Void Text Identity Text
    dotKeyChild)
        ParsecT Void Text Identity SingularPathElement
    -> ParsecT Void Text Identity SingularPathElement
    -> ParsecT Void Text Identity SingularPathElement
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> (Text -> SingularPathElement
    Key (Text -> SingularPathElement)
    -> ParsecT Void Text Identity Text
    -> ParsecT Void Text Identity SingularPathElement
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity Text -> ParsecT Void Text Identity Text
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try ParsecT Void Text Identity Text
    sqBrKeyChild)
        ParsecT Void Text Identity SingularPathElement
    -> ParsecT Void Text Identity SingularPathElement
    -> ParsecT Void Text Identity SingularPathElement
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> Int -> SingularPathElement
    Index (Int -> SingularPathElement)
    -> ParsecT Void Text Identity Int
    -> ParsecT Void Text Identity SingularPathElement
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity Int -> ParsecT Void Text Identity Int
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    inSqBr ParsecT Void Text Identity Int
    indexChildWithoutBrackets

    orFilterExpr :: Parser a -> Parser FilterExpr
    orFilterExpr :: forall a. Parser a -> ParsecT Void Text Identity FilterExpr
    orFilterExpr Parser a
    endParser = do
      let orOperator :: ParsecT Void Text Identity (Tokens Text)
    orOperator = ParsecT Void Text Identity (Tokens Text)
    -> ParsecT Void Text Identity (Tokens Text)
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    ignoreSurroundingSpace (ParsecT Void Text Identity (Tokens Text)
     -> ParsecT Void Text Identity (Tokens Text))
    -> ParsecT Void Text Identity (Tokens Text)
    -> ParsecT Void Text Identity (Tokens Text)
    forall a b. (a -> b) -> a -> b
    $ Tokens Text -> ParsecT Void Text Identity (Tokens Text)
    forall e s (m :: * -> *).
    MonadParsec e s m =>
    Tokens s -> m (Tokens s)
    string Tokens Text
    "||"
      e1 <-
        -- If there is an '&&' operation, it should take precedence over the '||'
        ParsecT Void Text Identity FilterExpr
    -> ParsecT Void Text Identity FilterExpr
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try (ParsecT Void Text Identity Text
    -> ParsecT Void Text Identity FilterExpr
    forall a. Parser a -> ParsecT Void Text Identity FilterExpr
    andFilterExpr ParsecT Void Text Identity Text
    orOperator)
          ParsecT Void Text Identity FilterExpr
    -> ParsecT Void Text Identity FilterExpr
    -> ParsecT Void Text Identity FilterExpr
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> ParsecT Void Text Identity Text
    -> ParsecT Void Text Identity FilterExpr
    forall a. Parser a -> ParsecT Void Text Identity FilterExpr
    basicFilterExpr ParsecT Void Text Identity Text
    orOperator
      _ <- orOperator
      Or e1 <$> filterExpr endParser

    andFilterExpr :: Parser a -> Parser FilterExpr
    andFilterExpr :: forall a. Parser a -> ParsecT Void Text Identity FilterExpr
    andFilterExpr Parser a
    endParser = do
      let andOperator :: ParsecT Void Text Identity (Tokens Text)
    andOperator = ParsecT Void Text Identity (Tokens Text)
    -> ParsecT Void Text Identity (Tokens Text)
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    ignoreSurroundingSpace (ParsecT Void Text Identity (Tokens Text)
     -> ParsecT Void Text Identity (Tokens Text))
    -> ParsecT Void Text Identity (Tokens Text)
    -> ParsecT Void Text Identity (Tokens Text)
    forall a b. (a -> b) -> a -> b
    $ Tokens Text -> ParsecT Void Text Identity (Tokens Text)
    forall e s (m :: * -> *).
    MonadParsec e s m =>
    Tokens s -> m (Tokens s)
    string Tokens Text
    "&&"
      e1 <- ParsecT Void Text Identity Text
    -> ParsecT Void Text Identity FilterExpr
    forall a. Parser a -> ParsecT Void Text Identity FilterExpr
    basicFilterExpr ParsecT Void Text Identity Text
    andOperator
      _ <- andOperator
      And e1 <$> filterExpr endParser

    search :: Parser JSONPathElement
    search :: ParsecT Void Text Identity JSONPathElement
    search = do
      _ <- Token Text -> ParsecT Void Text Identity (Token Text)
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    Token s -> m (Token s)
    char Char
    Token Text
    '.'
      _ <- lookAhead (char '.')
      Search <$> some jsonPathElement

    searchBeginningWithSlice :: Parser JSONPathElement
    searchBeginningWithSlice :: ParsecT Void Text Identity JSONPathElement
    searchBeginningWithSlice = do
      _ <- Tokens Text -> ParsecT Void Text Identity (Tokens Text)
    forall e s (m :: * -> *).
    MonadParsec e s m =>
    Tokens s -> m (Tokens s)
    string Tokens Text
    ".."
      _ <- lookAhead (char '[')
      Search <$> some jsonPathElement

    beginningPoint :: Parser BeginningPoint
    beginningPoint :: ParsecT Void Text Identity BeginningPoint
    beginningPoint =
      ParsecT Void Text Identity BeginningPoint
    -> ParsecT Void Text Identity BeginningPoint
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
    try (Token Text -> ParsecT Void Text Identity (Token Text)
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    Token s -> m (Token s)
    char Char
    Token Text
    '$' ParsecT Void Text Identity Char
    -> BeginningPoint -> ParsecT Void Text Identity BeginningPoint
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> BeginningPoint
    Root)
        ParsecT Void Text Identity BeginningPoint
    -> ParsecT Void Text Identity BeginningPoint
    -> ParsecT Void Text Identity BeginningPoint
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> (Token Text -> ParsecT Void Text Identity (Token Text)
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    Token s -> m (Token s)
    char Char
    Token Text
    '@' ParsecT Void Text Identity Char
    -> BeginningPoint -> ParsecT Void Text Identity BeginningPoint
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> BeginningPoint
    CurrentObject)

    condition :: Parser Condition
    condition :: Parser Condition
    condition =
      Parser Condition -> Parser Condition
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    ignoreSurroundingSpace (Parser Condition -> Parser Condition)
    -> Parser Condition -> Parser Condition
    forall a b. (a -> b) -> a -> b
    $
        Tokens Text -> ParsecT Void Text Identity (Tokens Text)
    forall e s (m :: * -> *).
    MonadParsec e s m =>
    Tokens s -> m (Tokens s)
    string Tokens Text
    "==" ParsecT Void Text Identity (Tokens Text)
    -> Condition -> Parser Condition
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Condition
    Equal
          Parser Condition -> Parser Condition -> Parser Condition
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> Tokens Text -> ParsecT Void Text Identity (Tokens Text)
    forall e s (m :: * -> *).
    MonadParsec e s m =>
    Tokens s -> m (Tokens s)
    string Tokens Text
    "!=" ParsecT Void Text Identity (Tokens Text)
    -> Condition -> Parser Condition
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Condition
    NotEqual
          Parser Condition -> Parser Condition -> Parser Condition
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> Tokens Text -> ParsecT Void Text Identity (Tokens Text)
    forall e s (m :: * -> *).
    MonadParsec e s m =>
    Tokens s -> m (Tokens s)
    string Tokens Text
    "<=" ParsecT Void Text Identity (Tokens Text)
    -> Condition -> Parser Condition
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Condition
    SmallerThanOrEqual
          Parser Condition -> Parser Condition -> Parser Condition
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> Tokens Text -> ParsecT Void Text Identity (Tokens Text)
    forall e s (m :: * -> *).
    MonadParsec e s m =>
    Tokens s -> m (Tokens s)
    string Tokens Text
    ">=" ParsecT Void Text Identity (Tokens Text)
    -> Condition -> Parser Condition
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Condition
    GreaterThanOrEqual
          Parser Condition -> Parser Condition -> Parser Condition
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> Tokens Text -> ParsecT Void Text Identity (Tokens Text)
    forall e s (m :: * -> *).
    MonadParsec e s m =>
    Tokens s -> m (Tokens s)
    string Tokens Text
    ">" ParsecT Void Text Identity (Tokens Text)
    -> Condition -> Parser Condition
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Condition
    GreaterThan
          Parser Condition -> Parser Condition -> Parser Condition
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> Tokens Text -> ParsecT Void Text Identity (Tokens Text)
    forall e s (m :: * -> *).
    MonadParsec e s m =>
    Tokens s -> m (Tokens s)
    string Tokens Text
    "<" ParsecT Void Text Identity (Tokens Text)
    -> Condition -> Parser Condition
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Condition
    SmallerThan

    comparable :: Parser a -> Parser Comparable
    comparable :: forall a. Parser a -> ParsecT Void Text Identity Comparable
    comparable Parser a
    endParser = do
      Scientific -> Comparable
    CmpNumber (Scientific -> Comparable)
    -> ParsecT Void Text Identity Scientific
    -> ParsecT Void Text Identity Comparable
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity Scientific
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    m Scientific
    L.scientific
        ParsecT Void Text Identity Comparable
    -> ParsecT Void Text Identity Comparable
    -> ParsecT Void Text Identity Comparable
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> Text -> Comparable
    CmpString (Text -> Comparable)
    -> ParsecT Void Text Identity Text
    -> ParsecT Void Text Identity Comparable
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity Text
    quotedString
        ParsecT Void Text Identity Comparable
    -> ParsecT Void Text Identity Comparable
    -> ParsecT Void Text Identity Comparable
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> Bool -> Comparable
    CmpBool (Bool -> Comparable)
    -> ParsecT Void Text Identity Bool
    -> ParsecT Void Text Identity Comparable
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Void Text Identity Bool
    bool
        ParsecT Void Text Identity Comparable
    -> ParsecT Void Text Identity Comparable
    -> ParsecT Void Text Identity Comparable
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> Comparable
    CmpNull Comparable
    -> ParsecT Void Text Identity (Tokens Text)
    -> ParsecT Void Text Identity Comparable
    forall a b.
    a -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Tokens Text -> ParsecT Void Text Identity (Tokens Text)
    forall e s (m :: * -> *).
    MonadParsec e s m =>
    Tokens s -> m (Tokens s)
    string Tokens Text
    "null"
        ParsecT Void Text Identity Comparable
    -> ParsecT Void Text Identity Comparable
    -> ParsecT Void Text Identity Comparable
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> SingularPath -> Comparable
    CmpPath (SingularPath -> Comparable)
    -> ParsecT Void Text Identity SingularPath
    -> ParsecT Void Text Identity Comparable
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser a -> ParsecT Void Text Identity SingularPath
    forall a. Parser a -> ParsecT Void Text Identity SingularPath
    singularPath Parser a
    endParser

    bool :: Parser Bool
    bool :: ParsecT Void Text Identity Bool
    bool =
      Bool
    True Bool
    -> ParsecT Void Text Identity (Tokens Text)
    -> ParsecT Void Text Identity Bool
    forall a b.
    a -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Tokens Text -> ParsecT Void Text Identity (Tokens Text)
    forall e s (m :: * -> *).
    MonadParsec e s m =>
    Tokens s -> m (Tokens s)
    string Tokens Text
    "true"
        ParsecT Void Text Identity Bool
    -> ParsecT Void Text Identity Bool
    -> ParsecT Void Text Identity Bool
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> Bool
    False Bool
    -> ParsecT Void Text Identity (Tokens Text)
    -> ParsecT Void Text Identity Bool
    forall a b.
    a -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Tokens Text -> ParsecT Void Text Identity (Tokens Text)
    forall e s (m :: * -> *).
    MonadParsec e s m =>
    Tokens s -> m (Tokens s)
    string Tokens Text
    "false"

    ignoreSurroundingSpace :: Parser a -> Parser a
    ignoreSurroundingSpace :: forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    ignoreSurroundingSpace Parser a
    p = ParsecT Void Text Identity ()
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    m ()
    space ParsecT Void Text Identity () -> Parser a -> Parser a
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser a
    p Parser a -> ParsecT Void Text Identity () -> Parser a
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity ()
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    m ()
    space

    inSqBr :: Parser a -> Parser a
    inSqBr :: forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    inSqBr Parser a
    p = ParsecT Void Text Identity Char
    openingSqBr ParsecT Void Text Identity Char -> Parser a -> Parser a
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser a
    p Parser a -> ParsecT Void Text Identity Char -> Parser a
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity Char
    closingSqBr

    openingSqBr :: Parser Char
    openingSqBr :: ParsecT Void Text Identity Char
    openingSqBr = ParsecT Void Text Identity Char -> ParsecT Void Text Identity Char
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    ignoreSurroundingSpace (Token Text -> ParsecT Void Text Identity (Token Text)
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    Token s -> m (Token s)
    char Char
    Token Text
    '[')

    closingSqBr :: Parser Char
    closingSqBr :: ParsecT Void Text Identity Char
    closingSqBr = ParsecT Void Text Identity Char -> ParsecT Void Text Identity Char
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    ignoreSurroundingSpace (Token Text -> ParsecT Void Text Identity (Token Text)
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    Token s -> m (Token s)
    char Char
    Token Text
    ']')

    inParens :: Parser a -> Parser a
    inParens :: forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    inParens Parser a
    p = ParsecT Void Text Identity Char
    openingParen ParsecT Void Text Identity Char -> Parser a -> Parser a
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Parser a
    p Parser a -> ParsecT Void Text Identity Char -> Parser a
    forall a b.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Void Text Identity Char
    closingParen

    openingParen :: Parser Char
    openingParen :: ParsecT Void Text Identity Char
    openingParen = ParsecT Void Text Identity Char -> ParsecT Void Text Identity Char
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    ignoreSurroundingSpace (Token Text -> ParsecT Void Text Identity (Token Text)
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    Token s -> m (Token s)
    char Char
    Token Text
    '(')

    closingParen :: Parser Char
    closingParen :: ParsecT Void Text Identity Char
    closingParen = ParsecT Void Text Identity Char -> ParsecT Void Text Identity Char
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    ignoreSurroundingSpace (Token Text -> ParsecT Void Text Identity (Token Text)
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    Token s -> m (Token s)
    char Char
    Token Text
    ')')

    quotedString :: Parser Text
    quotedString :: ParsecT Void Text Identity Text
    quotedString = ParsecT Void Text Identity Text -> ParsecT Void Text Identity Text
    forall a.
    ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    ignoreSurroundingSpace (ParsecT Void Text Identity Text
     -> ParsecT Void Text Identity Text)
    -> ParsecT Void Text Identity Text
    -> ParsecT Void Text Identity Text
    forall a b. (a -> b) -> a -> b
    $ String -> Text
    Text.pack (String -> Text)
    -> ParsecT Void Text Identity String
    -> ParsecT Void Text Identity Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Char -> ParsecT Void Text Identity String
    forall {s} {f :: * -> *} {e}.
    (Token s ~ Char, MonadParsec e s f) =>
    Char -> f String
    inQuotes Char
    '"' ParsecT Void Text Identity String
    -> ParsecT Void Text Identity String
    -> ParsecT Void Text Identity String
    forall a.
    ParsecT Void Text Identity a
    -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> Char -> ParsecT Void Text Identity String
    forall {s} {f :: * -> *} {e}.
    (Token s ~ Char, MonadParsec e s f) =>
    Char -> f String
    inQuotes Char
    '\'')
      where
        inQuotes :: Char -> f String
    inQuotes Char
    quoteChar =
          Token s -> f (Token s)
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    Token s -> m (Token s)
    char Char
    Token s
    quoteChar f Char -> f String -> f String
    forall a b. f a -> f b -> f b
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> f Char -> f Char -> f String
    forall (m :: * -> *) a end. MonadPlus m => m a -> m end -> m [a]
    manyTill f Char
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    m Char
    L.charLiteral (Token s -> f (Token s)
    forall e s (m :: * -> *).
    (MonadParsec e s m, Token s ~ Char) =>
    Token s -> m (Token s)
    char Char
    Token s
    quoteChar)

    uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d
    uncurry3 :: forall a b c d. (a -> b -> c -> d) -> (a, b, c) -> d
    uncurry3 a -> b -> c -> d
    f (a
    a, b
    b, c
    c) = a -> b -> c -> d
    f a
    a b
    b c
    c