module Network.API.TheMovieDB.Types.Genre
( Genre (..),
)
where
import Data.Aeson
import Network.API.TheMovieDB.Internal.Types
data Genre = Genre
{
Genre -> ItemID
genreID :: ItemID,
Genre -> Text
genreName :: Text
}
deriving (Genre -> Genre -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Genre -> Genre -> Bool
$c/= :: Genre -> Genre -> Bool
== :: Genre -> Genre -> Bool
$c== :: Genre -> Genre -> Bool
Eq, ItemID -> Genre -> ShowS
[Genre] -> ShowS
Genre -> String
forall a.
(ItemID -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Genre] -> ShowS
$cshowList :: [Genre] -> ShowS
show :: Genre -> String
$cshow :: Genre -> String
showsPrec :: ItemID -> Genre -> ShowS
$cshowsPrec :: ItemID -> Genre -> ShowS
Show)
instance FromJSON Genre where
parseJSON :: Value -> Parser Genre
parseJSON = forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"Genre" forall a b. (a -> b) -> a -> b
$ \Object
v ->
ItemID -> Text -> Genre
Genre
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"id"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"name"