{-# 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
( fieldNameColon,
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 :: Parser (Argument s)
valueArgument =
String -> Parser (Argument s) -> Parser (Argument s)
forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
"Argument" (Parser (Argument s) -> Parser (Argument s))
-> Parser (Argument s) -> Parser (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 MyError ByteString Eventless Position
-> ParsecT
MyError ByteString Eventless (FieldName -> Value s -> Argument s)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT MyError ByteString Eventless Position
getLocation
ParsecT
MyError ByteString Eventless (FieldName -> Value s -> Argument s)
-> ParsecT MyError ByteString Eventless FieldName
-> ParsecT MyError ByteString Eventless (Value s -> Argument s)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT MyError ByteString Eventless FieldName
fieldNameColon
ParsecT MyError ByteString Eventless (Value s -> Argument s)
-> ParsecT MyError ByteString Eventless (Value s)
-> Parser (Argument s)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT MyError ByteString Eventless (Value s)
forall a. Parse a => Parser a
parse
maybeArguments :: Parse (Value s) => Parser (Arguments s)
maybeArguments :: Parser (Arguments s)
maybeArguments =
String -> Parser (Arguments s) -> Parser (Arguments s)
forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
"Arguments" (Parser (Arguments s) -> Parser (Arguments s))
-> Parser (Arguments s) -> Parser (Arguments s)
forall a b. (a -> b) -> a -> b
$
Parser (Argument s) -> Parser (Arguments s)
forall a coll k.
(FromElems Eventless a coll, Collection a coll, KeyOf k a) =>
Parser a -> Parser coll
uniqTupleOpt Parser (Argument s)
forall (s :: Stage). Parse (Value s) => Parser (Argument s)
valueArgument