module Hasura.Backends.DataConnector.IR.Table
  ( -- * Table
    Name (..),

    -- * Foreign Key Constraints
    ConstraintName (..),
  )
where

--------------------------------------------------------------------------------

import Data.Aeson (FromJSON (..), ToJSON, ToJSONKey (..), withText)
import Data.Aeson.Types (toJSONKeyText)
import Data.List.NonEmpty qualified as NonEmpty
import Data.Text qualified as Text
import Data.Text.Extended (ToTxt (..))
import Hasura.Backends.DataConnector.API qualified as API
import Hasura.Base.ErrorValue qualified as ErrorValue
import Hasura.Base.ToErrorValue (ToErrorValue (..))
import Hasura.Incremental (Cacheable)
import Hasura.Prelude
import Witch.From qualified as Witch

--------------------------------------------------------------------------------

-- | The fully qualified name of a table. The last element in the list is the table name
-- and all other elements represent namespacing of the table name.
-- For example, for a database that has schemas, the name would be '[<schema>,<table name>]'
newtype Name = Name {Name -> NonEmpty Text
unName :: NonEmpty Text}
  deriving stock (Typeable Name
DataType
Constr
Typeable Name
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Name -> c Name)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Name)
-> (Name -> Constr)
-> (Name -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Name))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Name))
-> ((forall b. Data b => b -> b) -> Name -> Name)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r)
-> (forall u. (forall d. Data d => d -> u) -> Name -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Name -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Name -> m Name)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Name -> m Name)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Name -> m Name)
-> Data Name
Name -> DataType
Name -> Constr
(forall b. Data b => b -> b) -> Name -> Name
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Name -> c Name
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Name
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Name -> u
forall u. (forall d. Data d => d -> u) -> Name -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Name -> m Name
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Name -> m Name
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Name
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Name -> c Name
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Name)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Name)
$cName :: Constr
$tName :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Name -> m Name
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Name -> m Name
gmapMp :: (forall d. Data d => d -> m d) -> Name -> m Name
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Name -> m Name
gmapM :: (forall d. Data d => d -> m d) -> Name -> m Name
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Name -> m Name
gmapQi :: Int -> (forall d. Data d => d -> u) -> Name -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Name -> u
gmapQ :: (forall d. Data d => d -> u) -> Name -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Name -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r
gmapT :: (forall b. Data b => b -> b) -> Name -> Name
$cgmapT :: (forall b. Data b => b -> b) -> Name -> Name
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Name)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Name)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Name)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Name)
dataTypeOf :: Name -> DataType
$cdataTypeOf :: Name -> DataType
toConstr :: Name -> Constr
$ctoConstr :: Name -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Name
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Name
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Name -> c Name
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Name -> c Name
$cp1Data :: Typeable Name
Data, Name -> Name -> Bool
(Name -> Name -> Bool) -> (Name -> Name -> Bool) -> Eq Name
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Name -> Name -> Bool
$c/= :: Name -> Name -> Bool
== :: Name -> Name -> Bool
$c== :: Name -> Name -> Bool
Eq, (forall x. Name -> Rep Name x)
-> (forall x. Rep Name x -> Name) -> Generic Name
forall x. Rep Name x -> Name
forall x. Name -> Rep Name x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Name x -> Name
$cfrom :: forall x. Name -> Rep Name x
Generic, Eq Name
Eq Name
-> (Name -> Name -> Ordering)
-> (Name -> Name -> Bool)
-> (Name -> Name -> Bool)
-> (Name -> Name -> Bool)
-> (Name -> Name -> Bool)
-> (Name -> Name -> Name)
-> (Name -> Name -> Name)
-> Ord Name
Name -> Name -> Bool
Name -> Name -> Ordering
Name -> Name -> Name
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
min :: Name -> Name -> Name
$cmin :: Name -> Name -> Name
max :: Name -> Name -> Name
$cmax :: Name -> Name -> Name
>= :: Name -> Name -> Bool
$c>= :: Name -> Name -> Bool
> :: Name -> Name -> Bool
$c> :: Name -> Name -> Bool
<= :: Name -> Name -> Bool
$c<= :: Name -> Name -> Bool
< :: Name -> Name -> Bool
$c< :: Name -> Name -> Bool
compare :: Name -> Name -> Ordering
$ccompare :: Name -> Name -> Ordering
$cp1Ord :: Eq Name
Ord, Int -> Name -> ShowS
[Name] -> ShowS
Name -> String
(Int -> Name -> ShowS)
-> (Name -> String) -> ([Name] -> ShowS) -> Show Name
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Name] -> ShowS
$cshowList :: [Name] -> ShowS
show :: Name -> String
$cshow :: Name -> String
showsPrec :: Int -> Name -> ShowS
$cshowsPrec :: Int -> Name -> ShowS
Show)
  deriving newtype (Eq Name
Eq Name -> (Accesses -> Name -> Name -> Bool) -> Cacheable Name
Accesses -> Name -> Name -> Bool
forall a. Eq a -> (Accesses -> a -> a -> Bool) -> Cacheable a
unchanged :: Accesses -> Name -> Name -> Bool
$cunchanged :: Accesses -> Name -> Name -> Bool
$cp1Cacheable :: Eq Name
Cacheable, Int -> Name -> Int
Name -> Int
(Int -> Name -> Int) -> (Name -> Int) -> Hashable Name
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: Name -> Int
$chash :: Name -> Int
hashWithSalt :: Int -> Name -> Int
$chashWithSalt :: Int -> Name -> Int
Hashable, Name -> ()
(Name -> ()) -> NFData Name
forall a. (a -> ()) -> NFData a
rnf :: Name -> ()
$crnf :: Name -> ()
NFData, [Name] -> Value
[Name] -> Encoding
Name -> Value
Name -> Encoding
(Name -> Value)
-> (Name -> Encoding)
-> ([Name] -> Value)
-> ([Name] -> Encoding)
-> ToJSON Name
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [Name] -> Encoding
$ctoEncodingList :: [Name] -> Encoding
toJSONList :: [Name] -> Value
$ctoJSONList :: [Name] -> Value
toEncoding :: Name -> Encoding
$ctoEncoding :: Name -> Encoding
toJSON :: Name -> Value
$ctoJSON :: Name -> Value
ToJSON)

instance FromJSON Name where
  parseJSON :: Value -> Parser Name
parseJSON Value
value =
    NonEmpty Text -> Name
Name (NonEmpty Text -> Name) -> Parser (NonEmpty Text) -> Parser Name
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser (NonEmpty Text)
forall a. FromJSON a => Value -> Parser a
parseJSON Value
value
      -- Fallback parsing of a single string to support older metadata
      Parser Name -> Parser Name -> Parser Name
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> String -> (Text -> Parser Name) -> Value -> Parser Name
forall a. String -> (Text -> Parser a) -> Value -> Parser a
withText String
"Name" (\Text
text -> Name -> Parser Name
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Name -> Parser Name)
-> (NonEmpty Text -> Name) -> NonEmpty Text -> Parser Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonEmpty Text -> Name
Name (NonEmpty Text -> Parser Name) -> NonEmpty Text -> Parser Name
forall a b. (a -> b) -> a -> b
$ Text
text Text -> [Text] -> NonEmpty Text
forall a. a -> [a] -> NonEmpty a
:| []) Value
value

instance ToJSONKey Name where
  toJSONKey :: ToJSONKeyFunction Name
toJSONKey = (Name -> Text) -> ToJSONKeyFunction Name
forall a. (a -> Text) -> ToJSONKeyFunction a
toJSONKeyText Name -> Text
forall a. ToTxt a => a -> Text
toTxt

instance Witch.From API.TableName Name where
  from :: TableName -> Name
from (API.TableName NonEmpty Text
n) = NonEmpty Text -> Name
Name NonEmpty Text
n

instance Witch.From Name API.TableName where
  from :: Name -> TableName
from (Name NonEmpty Text
n) = NonEmpty Text -> TableName
API.TableName NonEmpty Text
n

instance Witch.From Text Name where
  from :: Text -> Name
from = NonEmpty Text -> Name
Name (NonEmpty Text -> Name) -> (Text -> NonEmpty Text) -> Text -> Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> NonEmpty Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure

instance ToTxt Name where
  toTxt :: Name -> Text
toTxt = Text -> [Text] -> Text
Text.intercalate Text
"." ([Text] -> Text) -> (Name -> [Text]) -> Name -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonEmpty Text -> [Text]
forall a. NonEmpty a -> [a]
NonEmpty.toList (NonEmpty Text -> [Text])
-> (Name -> NonEmpty Text) -> Name -> [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> NonEmpty Text
unName

instance ToErrorValue Name where
  toErrorValue :: Name -> ErrorMessage
toErrorValue = Text -> ErrorMessage
ErrorValue.squote (Text -> ErrorMessage) -> (Name -> Text) -> Name -> ErrorMessage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> Text
forall a. ToTxt a => a -> Text
toTxt

--------------------------------------------------------------------------------

newtype ConstraintName = ConstraintName {ConstraintName -> Text
unConstraintName :: Text}
  deriving stock (ConstraintName -> ConstraintName -> Bool
(ConstraintName -> ConstraintName -> Bool)
-> (ConstraintName -> ConstraintName -> Bool) -> Eq ConstraintName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConstraintName -> ConstraintName -> Bool
$c/= :: ConstraintName -> ConstraintName -> Bool
== :: ConstraintName -> ConstraintName -> Bool
$c== :: ConstraintName -> ConstraintName -> Bool
Eq, Eq ConstraintName
Eq ConstraintName
-> (ConstraintName -> ConstraintName -> Ordering)
-> (ConstraintName -> ConstraintName -> Bool)
-> (ConstraintName -> ConstraintName -> Bool)
-> (ConstraintName -> ConstraintName -> Bool)
-> (ConstraintName -> ConstraintName -> Bool)
-> (ConstraintName -> ConstraintName -> ConstraintName)
-> (ConstraintName -> ConstraintName -> ConstraintName)
-> Ord ConstraintName
ConstraintName -> ConstraintName -> Bool
ConstraintName -> ConstraintName -> Ordering
ConstraintName -> ConstraintName -> ConstraintName
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
min :: ConstraintName -> ConstraintName -> ConstraintName
$cmin :: ConstraintName -> ConstraintName -> ConstraintName
max :: ConstraintName -> ConstraintName -> ConstraintName
$cmax :: ConstraintName -> ConstraintName -> ConstraintName
>= :: ConstraintName -> ConstraintName -> Bool
$c>= :: ConstraintName -> ConstraintName -> Bool
> :: ConstraintName -> ConstraintName -> Bool
$c> :: ConstraintName -> ConstraintName -> Bool
<= :: ConstraintName -> ConstraintName -> Bool
$c<= :: ConstraintName -> ConstraintName -> Bool
< :: ConstraintName -> ConstraintName -> Bool
$c< :: ConstraintName -> ConstraintName -> Bool
compare :: ConstraintName -> ConstraintName -> Ordering
$ccompare :: ConstraintName -> ConstraintName -> Ordering
$cp1Ord :: Eq ConstraintName
Ord, Int -> ConstraintName -> ShowS
[ConstraintName] -> ShowS
ConstraintName -> String
(Int -> ConstraintName -> ShowS)
-> (ConstraintName -> String)
-> ([ConstraintName] -> ShowS)
-> Show ConstraintName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConstraintName] -> ShowS
$cshowList :: [ConstraintName] -> ShowS
show :: ConstraintName -> String
$cshow :: ConstraintName -> String
showsPrec :: Int -> ConstraintName -> ShowS
$cshowsPrec :: Int -> ConstraintName -> ShowS
Show, (forall x. ConstraintName -> Rep ConstraintName x)
-> (forall x. Rep ConstraintName x -> ConstraintName)
-> Generic ConstraintName
forall x. Rep ConstraintName x -> ConstraintName
forall x. ConstraintName -> Rep ConstraintName x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConstraintName x -> ConstraintName
$cfrom :: forall x. ConstraintName -> Rep ConstraintName x
Generic, Typeable ConstraintName
DataType
Constr
Typeable ConstraintName
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> ConstraintName -> c ConstraintName)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ConstraintName)
-> (ConstraintName -> Constr)
-> (ConstraintName -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ConstraintName))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c ConstraintName))
-> ((forall b. Data b => b -> b)
    -> ConstraintName -> ConstraintName)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ConstraintName -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ConstraintName -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> ConstraintName -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> ConstraintName -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> ConstraintName -> m ConstraintName)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> ConstraintName -> m ConstraintName)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> ConstraintName -> m ConstraintName)
-> Data ConstraintName
ConstraintName -> DataType
ConstraintName -> Constr
(forall b. Data b => b -> b) -> ConstraintName -> ConstraintName
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ConstraintName -> c ConstraintName
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ConstraintName
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> ConstraintName -> u
forall u. (forall d. Data d => d -> u) -> ConstraintName -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ConstraintName -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ConstraintName -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ConstraintName -> m ConstraintName
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ConstraintName -> m ConstraintName
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ConstraintName
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ConstraintName -> c ConstraintName
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ConstraintName)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ConstraintName)
$cConstraintName :: Constr
$tConstraintName :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> ConstraintName -> m ConstraintName
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ConstraintName -> m ConstraintName
gmapMp :: (forall d. Data d => d -> m d)
-> ConstraintName -> m ConstraintName
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ConstraintName -> m ConstraintName
gmapM :: (forall d. Data d => d -> m d)
-> ConstraintName -> m ConstraintName
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ConstraintName -> m ConstraintName
gmapQi :: Int -> (forall d. Data d => d -> u) -> ConstraintName -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> ConstraintName -> u
gmapQ :: (forall d. Data d => d -> u) -> ConstraintName -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ConstraintName -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ConstraintName -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ConstraintName -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ConstraintName -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ConstraintName -> r
gmapT :: (forall b. Data b => b -> b) -> ConstraintName -> ConstraintName
$cgmapT :: (forall b. Data b => b -> b) -> ConstraintName -> ConstraintName
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ConstraintName)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ConstraintName)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c ConstraintName)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ConstraintName)
dataTypeOf :: ConstraintName -> DataType
$cdataTypeOf :: ConstraintName -> DataType
toConstr :: ConstraintName -> Constr
$ctoConstr :: ConstraintName -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ConstraintName
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ConstraintName
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ConstraintName -> c ConstraintName
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ConstraintName -> c ConstraintName
$cp1Data :: Typeable ConstraintName
Data)
  deriving newtype (ConstraintName -> ()
(ConstraintName -> ()) -> NFData ConstraintName
forall a. (a -> ()) -> NFData a
rnf :: ConstraintName -> ()
$crnf :: ConstraintName -> ()
NFData, Int -> ConstraintName -> Int
ConstraintName -> Int
(Int -> ConstraintName -> Int)
-> (ConstraintName -> Int) -> Hashable ConstraintName
forall a. (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: ConstraintName -> Int
$chash :: ConstraintName -> Int
hashWithSalt :: Int -> ConstraintName -> Int
$chashWithSalt :: Int -> ConstraintName -> Int
Hashable, Eq ConstraintName
Eq ConstraintName
-> (Accesses -> ConstraintName -> ConstraintName -> Bool)
-> Cacheable ConstraintName
Accesses -> ConstraintName -> ConstraintName -> Bool
forall a. Eq a -> (Accesses -> a -> a -> Bool) -> Cacheable a
unchanged :: Accesses -> ConstraintName -> ConstraintName -> Bool
$cunchanged :: Accesses -> ConstraintName -> ConstraintName -> Bool
$cp1Cacheable :: Eq ConstraintName
Cacheable, Value -> Parser [ConstraintName]
Value -> Parser ConstraintName
(Value -> Parser ConstraintName)
-> (Value -> Parser [ConstraintName]) -> FromJSON ConstraintName
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ConstraintName]
$cparseJSONList :: Value -> Parser [ConstraintName]
parseJSON :: Value -> Parser ConstraintName
$cparseJSON :: Value -> Parser ConstraintName
FromJSON, [ConstraintName] -> Value
[ConstraintName] -> Encoding
ConstraintName -> Value
ConstraintName -> Encoding
(ConstraintName -> Value)
-> (ConstraintName -> Encoding)
-> ([ConstraintName] -> Value)
-> ([ConstraintName] -> Encoding)
-> ToJSON ConstraintName
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ConstraintName] -> Encoding
$ctoEncodingList :: [ConstraintName] -> Encoding
toJSONList :: [ConstraintName] -> Value
$ctoJSONList :: [ConstraintName] -> Value
toEncoding :: ConstraintName -> Encoding
$ctoEncoding :: ConstraintName -> Encoding
toJSON :: ConstraintName -> Value
$ctoJSON :: ConstraintName -> Value
ToJSON)

instance Witch.From API.ConstraintName ConstraintName where
  from :: ConstraintName -> ConstraintName
from = ConstraintName -> ConstraintName
coerce

instance Witch.From ConstraintName API.ConstraintName where
  from :: ConstraintName -> ConstraintName
from = ConstraintName -> ConstraintName
coerce

instance ToTxt ConstraintName where
  toTxt :: ConstraintName -> Text
toTxt = ConstraintName -> Text
coerce

instance ToErrorValue ConstraintName where
  toErrorValue :: ConstraintName -> ErrorMessage
toErrorValue = Text -> ErrorMessage
ErrorValue.squote (Text -> ErrorMessage)
-> (ConstraintName -> Text) -> ConstraintName -> ErrorMessage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConstraintName -> Text
coerce