From 5a6709030ceee63adb417c0fa2d2abce24c5d5cb Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Thu, 17 Dec 2020 20:42:47 +0100 Subject: Add show instances for AST type representation --- src/Language/GraphQL/AST/Document.hs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/Language/GraphQL/AST') diff --git a/src/Language/GraphQL/AST/Document.hs b/src/Language/GraphQL/AST/Document.hs index b30271c..a134f35 100644 --- a/src/Language/GraphQL/AST/Document.hs +++ b/src/Language/GraphQL/AST/Document.hs @@ -281,7 +281,12 @@ data Type = TypeNamed Name | TypeList Type | TypeNonNull NonNullType - deriving (Eq, Show) + deriving Eq + +instance Show Type where + show (TypeNamed typeName) = Text.unpack typeName + show (TypeList listType) = concat ["[", show listType, "]"] + show (TypeNonNull nonNullType) = show nonNullType -- | Represents type names. type NamedType = Name @@ -290,7 +295,11 @@ type NamedType = Name data NonNullType = NonNullTypeNamed Name | NonNullTypeList Type - deriving (Eq, Show) + deriving Eq + +instance Show NonNullType where + show (NonNullTypeNamed typeName) = '!' : Text.unpack typeName + show (NonNullTypeList listType) = concat ["![", show listType, "]"] -- ** Directives -- cgit v1.2.3