module Mpv.Data.EventName where import Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON), withText) data EventName = FileLoaded | EndFile | Pause | Unknown | Other Text deriving stock (EventName -> EventName -> Bool (EventName -> EventName -> Bool) -> (EventName -> EventName -> Bool) -> Eq EventName forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: EventName -> EventName -> Bool $c/= :: EventName -> EventName -> Bool == :: EventName -> EventName -> Bool $c== :: EventName -> EventName -> Bool Eq, Int -> EventName -> ShowS [EventName] -> ShowS EventName -> String (Int -> EventName -> ShowS) -> (EventName -> String) -> ([EventName] -> ShowS) -> Show EventName forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [EventName] -> ShowS $cshowList :: [EventName] -> ShowS show :: EventName -> String $cshow :: EventName -> String showsPrec :: Int -> EventName -> ShowS $cshowsPrec :: Int -> EventName -> ShowS Show, (forall x. EventName -> Rep EventName x) -> (forall x. Rep EventName x -> EventName) -> Generic EventName forall x. Rep EventName x -> EventName forall x. EventName -> Rep EventName x forall a. (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a $cto :: forall x. Rep EventName x -> EventName $cfrom :: forall x. EventName -> Rep EventName x Generic) eventNameText :: EventName -> Text eventNameText :: EventName -> Text eventNameText = \case EventName FileLoaded -> Text "file-loaded" EventName EndFile -> Text "end-file" EventName Pause -> Text "pause" EventName Unknown -> Text "unknown" Other Text t -> Text t instance FromJSON EventName where parseJSON :: Value -> Parser EventName parseJSON = String -> (Text -> Parser EventName) -> Value -> Parser EventName forall a. String -> (Text -> Parser a) -> Value -> Parser a withText String "EventName" \case Text "file-loaded" -> EventName -> Parser EventName forall (f :: * -> *) a. Applicative f => a -> f a pure EventName FileLoaded Text "end-file" -> EventName -> Parser EventName forall (f :: * -> *) a. Applicative f => a -> f a pure EventName EndFile Text "pause" -> EventName -> Parser EventName forall (f :: * -> *) a. Applicative f => a -> f a pure EventName Pause Text t -> EventName -> Parser EventName forall (f :: * -> *) a. Applicative f => a -> f a pure (Text -> EventName Other Text t) instance ToJSON EventName where toJSON :: EventName -> Value toJSON = Text -> Value forall a. ToJSON a => a -> Value toJSON (Text -> Value) -> (EventName -> Text) -> EventName -> Value forall b c a. (b -> c) -> (a -> b) -> a -> c . EventName -> Text eventNameText