{-# LANGUAGE CPP #-}
module GitHub.Data.Name (
    Name(..),
    mkName,
    untagName,
    ) where

import Prelude ()
import GitHub.Internal.Prelude

#if MIN_VERSION_aeson(1,0,0)
import Data.Aeson.Types
       (FromJSONKey (..), ToJSONKey (..), fromJSONKeyCoerce, toJSONKeyText)
#endif

newtype Name entity = N Text
    deriving (Name entity -> Name entity -> Bool
(Name entity -> Name entity -> Bool)
-> (Name entity -> Name entity -> Bool) -> Eq (Name entity)
forall entity. Name entity -> Name entity -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall entity. Name entity -> Name entity -> Bool
== :: Name entity -> Name entity -> Bool
$c/= :: forall entity. Name entity -> Name entity -> Bool
/= :: Name entity -> Name entity -> Bool
Eq, Eq (Name entity)
Eq (Name entity) =>
(Name entity -> Name entity -> Ordering)
-> (Name entity -> Name entity -> Bool)
-> (Name entity -> Name entity -> Bool)
-> (Name entity -> Name entity -> Bool)
-> (Name entity -> Name entity -> Bool)
-> (Name entity -> Name entity -> Name entity)
-> (Name entity -> Name entity -> Name entity)
-> Ord (Name entity)
Name entity -> Name entity -> Bool
Name entity -> Name entity -> Ordering
Name entity -> Name entity -> Name entity
forall entity. Eq (Name entity)
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
forall entity. Name entity -> Name entity -> Bool
forall entity. Name entity -> Name entity -> Ordering
forall entity. Name entity -> Name entity -> Name entity
$ccompare :: forall entity. Name entity -> Name entity -> Ordering
compare :: Name entity -> Name entity -> Ordering
$c< :: forall entity. Name entity -> Name entity -> Bool
< :: Name entity -> Name entity -> Bool
$c<= :: forall entity. Name entity -> Name entity -> Bool
<= :: Name entity -> Name entity -> Bool
$c> :: forall entity. Name entity -> Name entity -> Bool
> :: Name entity -> Name entity -> Bool
$c>= :: forall entity. Name entity -> Name entity -> Bool
>= :: Name entity -> Name entity -> Bool
$cmax :: forall entity. Name entity -> Name entity -> Name entity
max :: Name entity -> Name entity -> Name entity
$cmin :: forall entity. Name entity -> Name entity -> Name entity
min :: Name entity -> Name entity -> Name entity
Ord, Int -> Name entity -> ShowS
[Name entity] -> ShowS
Name entity -> String
(Int -> Name entity -> ShowS)
-> (Name entity -> String)
-> ([Name entity] -> ShowS)
-> Show (Name entity)
forall entity. Int -> Name entity -> ShowS
forall entity. [Name entity] -> ShowS
forall entity. Name entity -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall entity. Int -> Name entity -> ShowS
showsPrec :: Int -> Name entity -> ShowS
$cshow :: forall entity. Name entity -> String
show :: Name entity -> String
$cshowList :: forall entity. [Name entity] -> ShowS
showList :: [Name entity] -> ShowS
Show, (forall x. Name entity -> Rep (Name entity) x)
-> (forall x. Rep (Name entity) x -> Name entity)
-> Generic (Name entity)
forall x. Rep (Name entity) x -> Name entity
forall x. Name entity -> Rep (Name entity) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall entity x. Rep (Name entity) x -> Name entity
forall entity x. Name entity -> Rep (Name entity) x
$cfrom :: forall entity x. Name entity -> Rep (Name entity) x
from :: forall x. Name entity -> Rep (Name entity) x
$cto :: forall entity x. Rep (Name entity) x -> Name entity
to :: forall x. Rep (Name entity) x -> Name entity
Generic, Typeable, Typeable (Name entity)
Typeable (Name entity) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Name entity -> c (Name entity))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Name entity))
-> (Name entity -> Constr)
-> (Name entity -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Name entity)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Name entity)))
-> ((forall b. Data b => b -> b) -> Name entity -> Name entity)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Name entity -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Name entity -> r)
-> (forall u. (forall d. Data d => d -> u) -> Name entity -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Name entity -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Name entity -> m (Name entity))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Name entity -> m (Name entity))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Name entity -> m (Name entity))
-> Data (Name entity)
Name entity -> Constr
Name entity -> DataType
(forall b. Data b => b -> b) -> Name entity -> Name entity
forall entity. Data entity => Typeable (Name entity)
forall entity. Data entity => Name entity -> Constr
forall entity. Data entity => Name entity -> DataType
forall entity.
Data entity =>
(forall b. Data b => b -> b) -> Name entity -> Name entity
forall entity u.
Data entity =>
Int -> (forall d. Data d => d -> u) -> Name entity -> u
forall entity u.
Data entity =>
(forall d. Data d => d -> u) -> Name entity -> [u]
forall entity r r'.
Data entity =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Name entity -> r
forall entity r r'.
Data entity =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Name entity -> r
forall entity (m :: * -> *).
(Data entity, Monad m) =>
(forall d. Data d => d -> m d) -> Name entity -> m (Name entity)
forall entity (m :: * -> *).
(Data entity, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Name entity -> m (Name entity)
forall entity (c :: * -> *).
Data entity =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Name entity)
forall entity (c :: * -> *).
Data entity =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Name entity -> c (Name entity)
forall entity (t :: * -> *) (c :: * -> *).
(Data entity, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Name entity))
forall entity (t :: * -> * -> *) (c :: * -> *).
(Data entity, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Name entity))
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 entity -> u
forall u. (forall d. Data d => d -> u) -> Name entity -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Name entity -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Name entity -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Name entity -> m (Name entity)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Name entity -> m (Name entity)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Name entity)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Name entity -> c (Name entity)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Name entity))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Name entity))
$cgfoldl :: forall entity (c :: * -> *).
Data entity =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Name entity -> c (Name entity)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Name entity -> c (Name entity)
$cgunfold :: forall entity (c :: * -> *).
Data entity =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Name entity)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Name entity)
$ctoConstr :: forall entity. Data entity => Name entity -> Constr
toConstr :: Name entity -> Constr
$cdataTypeOf :: forall entity. Data entity => Name entity -> DataType
dataTypeOf :: Name entity -> DataType
$cdataCast1 :: forall entity (t :: * -> *) (c :: * -> *).
(Data entity, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Name entity))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Name entity))
$cdataCast2 :: forall entity (t :: * -> * -> *) (c :: * -> *).
(Data entity, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Name entity))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Name entity))
$cgmapT :: forall entity.
Data entity =>
(forall b. Data b => b -> b) -> Name entity -> Name entity
gmapT :: (forall b. Data b => b -> b) -> Name entity -> Name entity
$cgmapQl :: forall entity r r'.
Data entity =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Name entity -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Name entity -> r
$cgmapQr :: forall entity r r'.
Data entity =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Name entity -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Name entity -> r
$cgmapQ :: forall entity u.
Data entity =>
(forall d. Data d => d -> u) -> Name entity -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Name entity -> [u]
$cgmapQi :: forall entity u.
Data entity =>
Int -> (forall d. Data d => d -> u) -> Name entity -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Name entity -> u
$cgmapM :: forall entity (m :: * -> *).
(Data entity, Monad m) =>
(forall d. Data d => d -> m d) -> Name entity -> m (Name entity)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Name entity -> m (Name entity)
$cgmapMp :: forall entity (m :: * -> *).
(Data entity, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Name entity -> m (Name entity)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Name entity -> m (Name entity)
$cgmapMo :: forall entity (m :: * -> *).
(Data entity, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Name entity -> m (Name entity)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Name entity -> m (Name entity)
Data)

-- | Smart constructor for 'Name'
mkName :: proxy entity -> Text -> Name entity
mkName :: forall (proxy :: * -> *) entity.
proxy entity -> Text -> Name entity
mkName proxy entity
_ = Text -> Name entity
forall entity. Text -> Name entity
N

untagName :: Name entity -> Text
untagName :: forall entity. Name entity -> Text
untagName (N Text
name) = Text
name

instance Hashable (Name entity)
instance Binary (Name entity)

instance NFData (Name entity) where
    rnf :: Name entity -> ()
rnf (N Text
s) = Text -> ()
forall a. NFData a => a -> ()
rnf Text
s

instance FromJSON (Name entity) where
    parseJSON :: Value -> Parser (Name entity)
parseJSON = (Text -> Name entity) -> Parser Text -> Parser (Name entity)
forall a b. (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> Name entity
forall entity. Text -> Name entity
N (Parser Text -> Parser (Name entity))
-> (Value -> Parser Text) -> Value -> Parser (Name entity)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Parser Text
forall a. FromJSON a => Value -> Parser a
parseJSON

instance ToJSON (Name entity) where
    toJSON :: Name entity -> Value
toJSON = Text -> Value
forall a. ToJSON a => a -> Value
toJSON (Text -> Value) -> (Name entity -> Text) -> Name entity -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name entity -> Text
forall entity. Name entity -> Text
untagName

instance IsString (Name entity) where
    fromString :: String -> Name entity
fromString = Text -> Name entity
forall entity. Text -> Name entity
N (Text -> Name entity) -> (String -> Text) -> String -> Name entity
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
forall a. IsString a => String -> a
fromString

#if MIN_VERSION_aeson(1,0,0)
-- | @since 0.15.0.0
instance ToJSONKey (Name entity) where
    toJSONKey :: ToJSONKeyFunction (Name entity)
toJSONKey = (Name entity -> Text) -> ToJSONKeyFunction (Name entity)
forall a. (a -> Text) -> ToJSONKeyFunction a
toJSONKeyText Name entity -> Text
forall entity. Name entity -> Text
untagName

-- | @since 0.15.0.0
instance FromJSONKey (Name entity) where
    fromJSONKey :: FromJSONKeyFunction (Name entity)
fromJSONKey = FromJSONKeyFunction (Name entity)
forall a. Coercible Text a => FromJSONKeyFunction a
fromJSONKeyCoerce
#endif