summaryrefslogtreecommitdiff
path: root/src/Language/GraphQL/AST/Transform.hs
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2019-11-03 10:42:10 +0100
committerEugen Wissner <belka@caraus.de>2019-11-03 11:00:18 +0100
commit73fc334bf8d7bd6d8b83143995844ca0968ceeda (patch)
tree0f4e2e31b5e3dd031a2fbd5f078eb741e5b3e931 /src/Language/GraphQL/AST/Transform.hs
parent417ff5da7d0db6c8e73a238c17368192a3515a93 (diff)
downloadgraphql-73fc334bf8d7bd6d8b83143995844ca0968ceeda.tar.gz
Move related modules to Language.GraphQL.AST
Fixes #18. - `Language.GraphQL.Encoder` moved to `Language.GraphQL.AST.Encoder`. - `Language.GraphQL.Parser` moved to `Language.GraphQL.AST.Parser`. - `Language.GraphQL.Lexer` moved to `Language.GraphQL.AST.Lexer`. - All `Language.GraphQL.AST.Value` data constructor prefixes were removed. The module should be imported qualified. - All `Language.GraphQL.AST.Core.Value` data constructor prefixes were removed. The module should be imported qualified. - `Language.GraphQL.AST.Transform` is now isn't exposed publically anymore.
Diffstat (limited to 'src/Language/GraphQL/AST/Transform.hs')
-rw-r--r--src/Language/GraphQL/AST/Transform.hs30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/Language/GraphQL/AST/Transform.hs b/src/Language/GraphQL/AST/Transform.hs
index 107e1c6..ea90bab 100644
--- a/src/Language/GraphQL/AST/Transform.hs
+++ b/src/Language/GraphQL/AST/Transform.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE TupleSections #-}
+
-- | After the document is parsed, before getting executed the AST is
-- transformed into a similar, simpler AST. This module is responsible for
-- this transformation.
@@ -113,20 +115,20 @@ argument :: Schema.Subs -> Full.Argument -> Maybe Core.Argument
argument subs (Full.Argument n v) = Core.Argument n <$> value subs v
value :: Schema.Subs -> Full.Value -> Maybe Core.Value
-value subs (Full.ValueVariable n) = subs n
-value _ (Full.ValueInt i) = pure $ Core.ValueInt i
-value _ (Full.ValueFloat f) = pure $ Core.ValueFloat f
-value _ (Full.ValueString x) = pure $ Core.ValueString x
-value _ (Full.ValueBoolean b) = pure $ Core.ValueBoolean b
-value _ Full.ValueNull = pure Core.ValueNull
-value _ (Full.ValueEnum e) = pure $ Core.ValueEnum e
-value subs (Full.ValueList l) =
- Core.ValueList <$> traverse (value subs) l
-value subs (Full.ValueObject o) =
- Core.ValueObject <$> traverse (objectField subs) o
-
-objectField :: Schema.Subs -> Full.ObjectField -> Maybe Core.ObjectField
-objectField subs (Full.ObjectField n v) = Core.ObjectField n <$> value subs v
+value subs (Full.Variable n) = subs n
+value _ (Full.Int i) = pure $ Core.Int i
+value _ (Full.Float f) = pure $ Core.Float f
+value _ (Full.String x) = pure $ Core.String x
+value _ (Full.Boolean b) = pure $ Core.Boolean b
+value _ Full.Null = pure Core.Null
+value _ (Full.Enum e) = pure $ Core.Enum e
+value subs (Full.List l) =
+ Core.List <$> traverse (value subs) l
+value subs (Full.Object o) =
+ Core.Object . HashMap.fromList <$> traverse (objectField subs) o
+
+objectField :: Schema.Subs -> Full.ObjectField -> Maybe (Core.Name, Core.Value)
+objectField subs (Full.ObjectField n v) = (n,) <$> value subs v
appendSelectionOpt ::
Traversable t =>