{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Data.Morpheus.Parsing.Internal.Arguments (maybeArguments) where
import Data.Morpheus.Parsing.Internal.Internal
( Parser,
getLocation,
)
import Data.Morpheus.Parsing.Internal.Terms
( colon,
parseName,
uniqTupleOpt,
)
import Data.Morpheus.Parsing.Internal.Value
( Parse (..),
)
import Data.Morpheus.Types.Internal.AST
( Argument (..),
Arguments,
Value,
)
import Relude
import Text.Megaparsec (label)
valueArgument :: Parse (Value s) => Parser (Argument s)
valueArgument :: forall (s :: Stage). Parse (Value s) => Parser (Argument s)
valueArgument =
String
-> ParsecT Void ByteString GQLResult (Argument s)
-> ParsecT Void ByteString GQLResult (Argument s)
forall a.
String
-> ParsecT Void ByteString GQLResult a
-> ParsecT Void ByteString GQLResult a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
"Argument" (ParsecT Void ByteString GQLResult (Argument s)
-> ParsecT Void ByteString GQLResult (Argument s))
-> ParsecT Void ByteString GQLResult (Argument s)
-> ParsecT Void ByteString GQLResult (Argument s)
forall a b. (a -> b) -> a -> b
$
Position -> FieldName -> Value s -> Argument s
forall (valid :: Stage).
Position -> FieldName -> Value valid -> Argument valid
Argument
(Position -> FieldName -> Value s -> Argument s)
-> ParsecT Void ByteString GQLResult Position
-> ParsecT
Void ByteString GQLResult (FieldName -> Value s -> Argument s)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Void ByteString GQLResult Position
getLocation
ParsecT
Void ByteString GQLResult (FieldName -> Value s -> Argument s)
-> ParsecT Void ByteString GQLResult FieldName
-> ParsecT Void ByteString GQLResult (Value s -> Argument s)
forall a b.
ParsecT Void ByteString GQLResult (a -> b)
-> ParsecT Void ByteString GQLResult a
-> ParsecT Void ByteString GQLResult b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (ParsecT Void ByteString GQLResult FieldName
forall (t :: NAME). Parser (Name t)
parseName ParsecT Void ByteString GQLResult FieldName
-> ParsecT Void ByteString GQLResult ()
-> ParsecT Void ByteString GQLResult FieldName
forall a b.
ParsecT Void ByteString GQLResult a
-> ParsecT Void ByteString GQLResult b
-> ParsecT Void ByteString GQLResult a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Void ByteString GQLResult ()
colon)
ParsecT Void ByteString GQLResult (Value s -> Argument s)
-> ParsecT Void ByteString GQLResult (Value s)
-> ParsecT Void ByteString GQLResult (Argument s)
forall a b.
ParsecT Void ByteString GQLResult (a -> b)
-> ParsecT Void ByteString GQLResult a
-> ParsecT Void ByteString GQLResult b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT Void ByteString GQLResult (Value s)
forall a. Parse a => Parser a
parse
{-# INLINEABLE valueArgument #-}
maybeArguments :: Parse (Value s) => Parser (Arguments s)
maybeArguments :: forall (s :: Stage). Parse (Value s) => Parser (Arguments s)
maybeArguments =
String
-> ParsecT
Void ByteString GQLResult (OrdMap FieldName (Argument s))
-> ParsecT
Void ByteString GQLResult (OrdMap FieldName (Argument s))
forall a.
String
-> ParsecT Void ByteString GQLResult a
-> ParsecT Void ByteString GQLResult a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
"Arguments" (ParsecT Void ByteString GQLResult (OrdMap FieldName (Argument s))
-> ParsecT
Void ByteString GQLResult (OrdMap FieldName (Argument s)))
-> ParsecT
Void ByteString GQLResult (OrdMap FieldName (Argument s))
-> ParsecT
Void ByteString GQLResult (OrdMap FieldName (Argument s))
forall a b. (a -> b) -> a -> b
$
Parser (Argument s)
-> ParsecT
Void ByteString GQLResult (OrdMap FieldName (Argument s))
forall (map :: * -> * -> *) k a.
(FromList GQLResult map k a, Empty (map k a), KeyOf k a) =>
Parser a -> Parser (map k a)
uniqTupleOpt Parser (Argument s)
forall (s :: Stage). Parse (Value s) => Parser (Argument s)
valueArgument
{-# INLINEABLE maybeArguments #-}