module GitHub.Data.Id (
Id(..),
mkId,
untagId,
) where
import GitHub.Internal.Prelude
import Prelude ()
newtype Id entity = Id Int
deriving (Eq, Ord, Show, Generic, Typeable, Data)
mkId :: proxy entity -> Int -> Id entity
mkId _ = Id
untagId :: Id entity -> Int
untagId (Id name) = name
instance Hashable (Id entity)
instance Binary (Id entity)
instance NFData (Id entity) where
rnf (Id s) = rnf s
instance FromJSON (Id entity) where
parseJSON = fmap Id . parseJSON
instance ToJSON (Id entity) where
toJSON = toJSON . untagId