diff options
| author | Eugen Wissner <belka@caraus.de> | 2019-12-25 06:45:29 +0100 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2019-12-25 06:45:29 +0100 |
| commit | 62f3c34bfedeb286d3639ff3ade68cdb3fe862b8 (patch) | |
| tree | 5b690b78a52652f62d27cb5bbd4ce09350731023 /src/Language/GraphQL/AST/Parser.hs | |
| parent | bdf711d69f71596e29328ae766c126c04f919267 (diff) | |
| download | graphql-62f3c34bfedeb286d3639ff3ade68cdb3fe862b8.tar.gz | |
Replace AST.Selection data constructors
Diffstat (limited to 'src/Language/GraphQL/AST/Parser.hs')
| -rw-r--r-- | src/Language/GraphQL/AST/Parser.hs | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/src/Language/GraphQL/AST/Parser.hs b/src/Language/GraphQL/AST/Parser.hs index 1505615..dfe1d4a 100644 --- a/src/Language/GraphQL/AST/Parser.hs +++ b/src/Language/GraphQL/AST/Parser.hs @@ -6,23 +6,19 @@ module Language.GraphQL.AST.Parser ( document ) where -import Control.Applicative ( Alternative(..) - , optional - ) +import Control.Applicative (Alternative(..), optional) import Data.List.NonEmpty (NonEmpty(..)) import Language.GraphQL.AST import Language.GraphQL.AST.Lexer -import Text.Megaparsec ( lookAhead - , option - , try - , (<?>) - ) +import Text.Megaparsec (lookAhead, option, try, (<?>)) -- | Parser for the GraphQL documents. document :: Parser Document -document = unicodeBOM >> spaceConsumer >> lexeme (manyNE definition) +document = unicodeBOM + >> spaceConsumer + >> lexeme (manyNE $ ExecutableDefinition <$> definition) -definition :: Parser Definition +definition :: Parser ExecutableDefinition definition = DefinitionOperation <$> operationDefinition <|> DefinitionFragment <$> fragmentDefinition <?> "definition error!" @@ -50,19 +46,20 @@ selectionSetOpt :: Parser SelectionSetOpt selectionSetOpt = braces $ some selection selection :: Parser Selection -selection = SelectionField <$> field - <|> try (SelectionFragmentSpread <$> fragmentSpread) - <|> SelectionInlineFragment <$> inlineFragment - <?> "selection error!" +selection = field + <|> try fragmentSpread + <|> inlineFragment + <?> "selection error!" -- * Field -field :: Parser Field -field = Field <$> optional alias - <*> name - <*> opt arguments - <*> opt directives - <*> opt selectionSetOpt +field :: Parser Selection +field = Field + <$> optional alias + <*> name + <*> opt arguments + <*> opt directives + <*> opt selectionSetOpt alias :: Parser Alias alias = try $ name <* colon @@ -77,16 +74,18 @@ argument = Argument <$> name <* colon <*> value -- * Fragments -fragmentSpread :: Parser FragmentSpread -fragmentSpread = FragmentSpread <$ spread - <*> fragmentName - <*> opt directives - -inlineFragment :: Parser InlineFragment -inlineFragment = InlineFragment <$ spread - <*> optional typeCondition - <*> opt directives - <*> selectionSet +fragmentSpread :: Parser Selection +fragmentSpread = FragmentSpread + <$ spread + <*> fragmentName + <*> opt directives + +inlineFragment :: Parser Selection +inlineFragment = InlineFragment + <$ spread + <*> optional typeCondition + <*> opt directives + <*> selectionSet fragmentDefinition :: Parser FragmentDefinition fragmentDefinition = FragmentDefinition |
