module Mpv.Data.Event where import Data.Aeson (ToJSON (toJSON), Value (Null)) import Data.GADT.Compare.TH (deriveGEq) import Data.GADT.Show.TH (deriveGShow) import Data.Some (Some, withSome) import qualified Mpv.Data.EventName as EventName import Mpv.Data.EventName (EventName) import qualified Mpv.Data.EventPayload as Payload data Event (name :: EventName) where EndFile :: Payload.EndFile -> Event 'EventName.EndFile FileLoaded :: Event 'EventName.FileLoaded Pause :: Event 'EventName.Pause Unknown :: Value -> Event 'EventName.Unknown deriveGEq ''Event deriveGShow ''Event instance ToJSON (Some Event) where toJSON :: Some Event -> Value toJSON Some Event e = Some Event -> (forall (a :: EventName). Event a -> Value) -> Value forall {k} (tag :: k -> *) b. Some tag -> (forall (a :: k). tag a -> b) -> b withSome Some Event e \case EndFile EndFile p -> EndFile -> Value forall a. ToJSON a => a -> Value toJSON EndFile p Event a FileLoaded -> Value Null Event a Pause -> Value Null Unknown Value p -> Value p