{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE OverloadedLists #-}

module Hasura.RQL.Types.Source.TableType (SourceTableType (..)) where

import Autodocodec
import Autodocodec.OpenAPI ()
import Control.DeepSeq (NFData)
import Data.Aeson (FromJSON, ToJSON)
import Data.Hashable (Hashable)
import GHC.Generics (Generic)
import Prelude

data SourceTableType = Table | View
  deriving stock (SourceTableType -> SourceTableType -> Bool
(SourceTableType -> SourceTableType -> Bool)
-> (SourceTableType -> SourceTableType -> Bool)
-> Eq SourceTableType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SourceTableType -> SourceTableType -> Bool
== :: SourceTableType -> SourceTableType -> Bool
$c/= :: SourceTableType -> SourceTableType -> Bool
/= :: SourceTableType -> SourceTableType -> Bool
Eq, Eq SourceTableType
Eq SourceTableType
-> (SourceTableType -> SourceTableType -> Ordering)
-> (SourceTableType -> SourceTableType -> Bool)
-> (SourceTableType -> SourceTableType -> Bool)
-> (SourceTableType -> SourceTableType -> Bool)
-> (SourceTableType -> SourceTableType -> Bool)
-> (SourceTableType -> SourceTableType -> SourceTableType)
-> (SourceTableType -> SourceTableType -> SourceTableType)
-> Ord SourceTableType
SourceTableType -> SourceTableType -> Bool
SourceTableType -> SourceTableType -> Ordering
SourceTableType -> SourceTableType -> SourceTableType
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: SourceTableType -> SourceTableType -> Ordering
compare :: SourceTableType -> SourceTableType -> Ordering
$c< :: SourceTableType -> SourceTableType -> Bool
< :: SourceTableType -> SourceTableType -> Bool
$c<= :: SourceTableType -> SourceTableType -> Bool
<= :: SourceTableType -> SourceTableType -> Bool
$c> :: SourceTableType -> SourceTableType -> Bool
> :: SourceTableType -> SourceTableType -> Bool
$c>= :: SourceTableType -> SourceTableType -> Bool
>= :: SourceTableType -> SourceTableType -> Bool
$cmax :: SourceTableType -> SourceTableType -> SourceTableType
max :: SourceTableType -> SourceTableType -> SourceTableType
$cmin :: SourceTableType -> SourceTableType -> SourceTableType
min :: SourceTableType -> SourceTableType -> SourceTableType
Ord, Int -> SourceTableType -> ShowS
[SourceTableType] -> ShowS
SourceTableType -> String
(Int -> SourceTableType -> ShowS)
-> (SourceTableType -> String)
-> ([SourceTableType] -> ShowS)
-> Show SourceTableType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SourceTableType -> ShowS
showsPrec :: Int -> SourceTableType -> ShowS
$cshow :: SourceTableType -> String
show :: SourceTableType -> String
$cshowList :: [SourceTableType] -> ShowS
showList :: [SourceTableType] -> ShowS
Show, (forall x. SourceTableType -> Rep SourceTableType x)
-> (forall x. Rep SourceTableType x -> SourceTableType)
-> Generic SourceTableType
forall x. Rep SourceTableType x -> SourceTableType
forall x. SourceTableType -> Rep SourceTableType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. SourceTableType -> Rep SourceTableType x
from :: forall x. SourceTableType -> Rep SourceTableType x
$cto :: forall x. Rep SourceTableType x -> SourceTableType
to :: forall x. Rep SourceTableType x -> SourceTableType
Generic, Int -> SourceTableType
SourceTableType -> Int
SourceTableType -> [SourceTableType]
SourceTableType -> SourceTableType
SourceTableType -> SourceTableType -> [SourceTableType]
SourceTableType
-> SourceTableType -> SourceTableType -> [SourceTableType]
(SourceTableType -> SourceTableType)
-> (SourceTableType -> SourceTableType)
-> (Int -> SourceTableType)
-> (SourceTableType -> Int)
-> (SourceTableType -> [SourceTableType])
-> (SourceTableType -> SourceTableType -> [SourceTableType])
-> (SourceTableType -> SourceTableType -> [SourceTableType])
-> (SourceTableType
    -> SourceTableType -> SourceTableType -> [SourceTableType])
-> Enum SourceTableType
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: SourceTableType -> SourceTableType
succ :: SourceTableType -> SourceTableType
$cpred :: SourceTableType -> SourceTableType
pred :: SourceTableType -> SourceTableType
$ctoEnum :: Int -> SourceTableType
toEnum :: Int -> SourceTableType
$cfromEnum :: SourceTableType -> Int
fromEnum :: SourceTableType -> Int
$cenumFrom :: SourceTableType -> [SourceTableType]
enumFrom :: SourceTableType -> [SourceTableType]
$cenumFromThen :: SourceTableType -> SourceTableType -> [SourceTableType]
enumFromThen :: SourceTableType -> SourceTableType -> [SourceTableType]
$cenumFromTo :: SourceTableType -> SourceTableType -> [SourceTableType]
enumFromTo :: SourceTableType -> SourceTableType -> [SourceTableType]
$cenumFromThenTo :: SourceTableType
-> SourceTableType -> SourceTableType -> [SourceTableType]
enumFromThenTo :: SourceTableType
-> SourceTableType -> SourceTableType -> [SourceTableType]
Enum, SourceTableType
SourceTableType -> SourceTableType -> Bounded SourceTableType
forall a. a -> a -> Bounded a
$cminBound :: SourceTableType
minBound :: SourceTableType
$cmaxBound :: SourceTableType
maxBound :: SourceTableType
Bounded)
  deriving anyclass (SourceTableType -> ()
(SourceTableType -> ()) -> NFData SourceTableType
forall a. (a -> ()) -> NFData a
$crnf :: SourceTableType -> ()
rnf :: SourceTableType -> ()
NFData, Eq SourceTableType
Eq SourceTableType
-> (Int -> SourceTableType -> Int)
-> (SourceTableType -> Int)
-> Hashable SourceTableType
Int -> SourceTableType -> Int
SourceTableType -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> SourceTableType -> Int
hashWithSalt :: Int -> SourceTableType -> Int
$chash :: SourceTableType -> Int
hash :: SourceTableType -> Int
Hashable)
  deriving (Value -> Parser [SourceTableType]
Value -> Parser SourceTableType
(Value -> Parser SourceTableType)
-> (Value -> Parser [SourceTableType]) -> FromJSON SourceTableType
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser SourceTableType
parseJSON :: Value -> Parser SourceTableType
$cparseJSONList :: Value -> Parser [SourceTableType]
parseJSONList :: Value -> Parser [SourceTableType]
FromJSON, [SourceTableType] -> Value
[SourceTableType] -> Encoding
SourceTableType -> Value
SourceTableType -> Encoding
(SourceTableType -> Value)
-> (SourceTableType -> Encoding)
-> ([SourceTableType] -> Value)
-> ([SourceTableType] -> Encoding)
-> ToJSON SourceTableType
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: SourceTableType -> Value
toJSON :: SourceTableType -> Value
$ctoEncoding :: SourceTableType -> Encoding
toEncoding :: SourceTableType -> Encoding
$ctoJSONList :: [SourceTableType] -> Value
toJSONList :: [SourceTableType] -> Value
$ctoEncodingList :: [SourceTableType] -> Encoding
toEncodingList :: [SourceTableType] -> Encoding
ToJSON) via Autodocodec SourceTableType

instance HasCodec SourceTableType where
  codec :: JSONCodec SourceTableType
codec = Text -> JSONCodec SourceTableType -> JSONCodec SourceTableType
forall input output.
Text -> ValueCodec input output -> ValueCodec input output
named Text
"TableType" (NonEmpty (SourceTableType, Text) -> JSONCodec SourceTableType
forall constant.
Eq constant =>
NonEmpty (constant, Text) -> JSONCodec constant
stringConstCodec [(SourceTableType
Table, Text
"table"), (SourceTableType
View, Text
"view")])