diff options
| author | Eugen Wissner <belka@caraus.de> | 2023-02-19 11:26:27 +0100 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2023-02-19 11:26:27 +0100 |
| commit | 7c146fe41620ebf2166d797cfc54070fd69f3fd8 (patch) | |
| tree | 1e72c25a1c158fde68a5d289eb8466e520826317 /src/Language/GraphQL/Class.hs | |
| parent | 5306730ff8c32d4a6bddb712cd5560d8c7ca4b0f (diff) | |
| download | graphql-spice-7c146fe41620ebf2166d797cfc54070fd69f3fd8.tar.gz | |
Add ToGraphQL and `romGraphQL` instances for Word
Diffstat (limited to 'src/Language/GraphQL/Class.hs')
| -rw-r--r-- | src/Language/GraphQL/Class.hs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Language/GraphQL/Class.hs b/src/Language/GraphQL/Class.hs index 3f52a13..b363fd0 100644 --- a/src/Language/GraphQL/Class.hs +++ b/src/Language/GraphQL/Class.hs @@ -14,6 +14,7 @@ module Language.GraphQL.Class import Data.Foldable (toList) import Data.Int (Int8, Int16, Int32, Int64) import Data.Text (Text) +import Data.Word (Word8, Word16, Word32, Word64) import qualified Data.Text.Read as Text.Read import Data.Vector (Vector) import qualified Data.Vector as Vector @@ -50,6 +51,21 @@ instance ToGraphQL Int32 where instance ToGraphQL Int64 where toGraphQL = Type.Int . fromIntegral +instance ToGraphQL Word where + toGraphQL = Type.Int . fromIntegral + +instance ToGraphQL Word8 where + toGraphQL = Type.Int . fromIntegral + +instance ToGraphQL Word16 where + toGraphQL = Type.Int . fromIntegral + +instance ToGraphQL Word32 where + toGraphQL = Type.Int . fromIntegral + +instance ToGraphQL Word64 where + toGraphQL = Type.Int . fromIntegral + instance ToGraphQL a => ToGraphQL [a] where toGraphQL = Type.List . fmap toGraphQL @@ -87,6 +103,21 @@ instance FromGraphQL Int32 where instance FromGraphQL Int64 where fromGraphQL = fromGraphQLToIntegral +instance FromGraphQL Word where + fromGraphQL = fromGraphQLToIntegral + +instance FromGraphQL Word8 where + fromGraphQL = fromGraphQLToIntegral + +instance FromGraphQL Word16 where + fromGraphQL = fromGraphQLToIntegral + +instance FromGraphQL Word32 where + fromGraphQL = fromGraphQLToIntegral + +instance FromGraphQL Word64 where + fromGraphQL = fromGraphQLToIntegral + instance FromGraphQL a => FromGraphQL [a] where fromGraphQL (Type.List value) = traverse fromGraphQL value fromGraphQL _ = Nothing |
