2018-06-27 16:11:32 +03:00
|
|
|
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
|
|
|
|
|
|
|
module Hasura.RQL.Instances where
|
|
|
|
|
|
|
|
import Hasura.Prelude
|
|
|
|
|
2019-11-27 01:49:42 +03:00
|
|
|
import qualified Data.HashMap.Strict as M
|
|
|
|
import qualified Data.HashSet as S
|
2020-02-13 20:38:23 +03:00
|
|
|
import qualified Data.URL.Template as UT
|
2019-11-27 01:49:42 +03:00
|
|
|
import qualified Language.GraphQL.Draft.Syntax as G
|
2019-12-15 16:28:23 +03:00
|
|
|
import qualified Language.Haskell.TH.Syntax as TH
|
2020-04-02 02:22:55 +03:00
|
|
|
import qualified Text.Regex.TDFA as TDFA
|
|
|
|
import qualified Text.Regex.TDFA.Pattern as TDFA
|
2019-12-15 16:28:23 +03:00
|
|
|
|
|
|
|
import Data.Functor.Product
|
|
|
|
import Data.GADT.Compare
|
|
|
|
import Instances.TH.Lift ()
|
2019-11-27 01:49:42 +03:00
|
|
|
|
|
|
|
instance NFData G.Argument
|
|
|
|
instance NFData G.Directive
|
|
|
|
instance NFData G.ExecutableDefinition
|
|
|
|
instance NFData G.Field
|
|
|
|
instance NFData G.FragmentDefinition
|
|
|
|
instance NFData G.FragmentSpread
|
|
|
|
instance NFData G.GType
|
|
|
|
instance NFData G.InlineFragment
|
|
|
|
instance NFData G.OperationDefinition
|
|
|
|
instance NFData G.OperationType
|
|
|
|
instance NFData G.Selection
|
|
|
|
instance NFData G.TypedOperationDefinition
|
|
|
|
instance NFData G.Value
|
|
|
|
instance NFData G.ValueConst
|
|
|
|
instance NFData G.VariableDefinition
|
|
|
|
instance (NFData a) => NFData (G.ObjectFieldG a)
|
2020-02-13 20:38:23 +03:00
|
|
|
instance NFData UT.Variable
|
|
|
|
instance NFData UT.TemplateItem
|
|
|
|
instance NFData UT.URLTemplate
|
2019-11-27 01:49:42 +03:00
|
|
|
|
|
|
|
deriving instance NFData G.Alias
|
|
|
|
deriving instance NFData G.EnumValue
|
|
|
|
deriving instance NFData G.ExecutableDocument
|
|
|
|
deriving instance NFData G.ListType
|
|
|
|
deriving instance NFData G.Name
|
|
|
|
deriving instance NFData G.NamedType
|
|
|
|
deriving instance NFData G.Nullability
|
|
|
|
deriving instance NFData G.StringValue
|
|
|
|
deriving instance NFData G.Variable
|
2020-02-13 20:38:23 +03:00
|
|
|
deriving instance NFData G.Description
|
2019-11-27 01:49:42 +03:00
|
|
|
deriving instance (NFData a) => NFData (G.ListValueG a)
|
|
|
|
deriving instance (NFData a) => NFData (G.ObjectValueG a)
|
2018-06-27 16:11:32 +03:00
|
|
|
|
|
|
|
instance (TH.Lift k, TH.Lift v) => TH.Lift (M.HashMap k v) where
|
|
|
|
lift m = [| M.fromList $(TH.lift $ M.toList m) |]
|
2019-01-28 19:45:10 +03:00
|
|
|
|
|
|
|
instance TH.Lift a => TH.Lift (S.HashSet a) where
|
|
|
|
lift s = [| S.fromList $(TH.lift $ S.toList s) |]
|
2019-12-15 16:28:23 +03:00
|
|
|
|
2020-04-02 02:22:55 +03:00
|
|
|
deriving instance TH.Lift TDFA.CompOption
|
|
|
|
deriving instance TH.Lift TDFA.DoPa
|
|
|
|
deriving instance TH.Lift TDFA.ExecOption
|
|
|
|
deriving instance TH.Lift TDFA.Pattern
|
|
|
|
deriving instance TH.Lift TDFA.PatternSet
|
|
|
|
deriving instance TH.Lift TDFA.PatternSetCharacterClass
|
|
|
|
deriving instance TH.Lift TDFA.PatternSetCollatingElement
|
|
|
|
deriving instance TH.Lift TDFA.PatternSetEquivalenceClass
|
|
|
|
|
2019-12-15 16:28:23 +03:00
|
|
|
instance (GEq f, GEq g) => GEq (Product f g) where
|
|
|
|
Pair a1 a2 `geq` Pair b1 b2
|
|
|
|
| Just Refl <- a1 `geq` b1
|
|
|
|
, Just Refl <- a2 `geq` b2
|
|
|
|
= Just Refl
|
|
|
|
| otherwise = Nothing
|
|
|
|
|
|
|
|
instance (GCompare f, GCompare g) => GCompare (Product f g) where
|
|
|
|
Pair a1 a2 `gcompare` Pair b1 b2 = case gcompare a1 b1 of
|
|
|
|
GLT -> GLT
|
|
|
|
GEQ -> case gcompare a2 b2 of
|
|
|
|
GLT -> GLT
|
|
|
|
GEQ -> GEQ
|
|
|
|
GGT -> GGT
|
|
|
|
GGT -> GGT
|