module Mpv.Data.Response where

import Polysemy.Time.Json (json)

import Mpv.Data.RequestId (RequestId)

newtype ResponseError =
  ResponseError { ResponseError -> Text
unResponseError :: Text }
  deriving stock (ResponseError -> ResponseError -> Bool
(ResponseError -> ResponseError -> Bool)
-> (ResponseError -> ResponseError -> Bool) -> Eq ResponseError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResponseError -> ResponseError -> Bool
$c/= :: ResponseError -> ResponseError -> Bool
== :: ResponseError -> ResponseError -> Bool
$c== :: ResponseError -> ResponseError -> Bool
Eq, Int -> ResponseError -> ShowS
[ResponseError] -> ShowS
ResponseError -> String
(Int -> ResponseError -> ShowS)
-> (ResponseError -> String)
-> ([ResponseError] -> ShowS)
-> Show ResponseError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResponseError] -> ShowS
$cshowList :: [ResponseError] -> ShowS
show :: ResponseError -> String
$cshow :: ResponseError -> String
showsPrec :: Int -> ResponseError -> ShowS
$cshowsPrec :: Int -> ResponseError -> ShowS
Show, (forall x. ResponseError -> Rep ResponseError x)
-> (forall x. Rep ResponseError x -> ResponseError)
-> Generic ResponseError
forall x. Rep ResponseError x -> ResponseError
forall x. ResponseError -> Rep ResponseError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResponseError x -> ResponseError
$cfrom :: forall x. ResponseError -> Rep ResponseError x
Generic)
  deriving newtype (String -> ResponseError
(String -> ResponseError) -> IsString ResponseError
forall a. (String -> a) -> IsString a
fromString :: String -> ResponseError
$cfromString :: String -> ResponseError
IsString)

json ''ResponseError

data Response fmt =
  Response {
    forall fmt. Response fmt -> RequestId
requestId :: RequestId,
    forall fmt. Response fmt -> Either ResponseError fmt
payload :: Either ResponseError fmt
  }
  deriving stock (Response fmt -> Response fmt -> Bool
(Response fmt -> Response fmt -> Bool)
-> (Response fmt -> Response fmt -> Bool) -> Eq (Response fmt)
forall fmt. Eq fmt => Response fmt -> Response fmt -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Response fmt -> Response fmt -> Bool
$c/= :: forall fmt. Eq fmt => Response fmt -> Response fmt -> Bool
== :: Response fmt -> Response fmt -> Bool
$c== :: forall fmt. Eq fmt => Response fmt -> Response fmt -> Bool
Eq, Int -> Response fmt -> ShowS
[Response fmt] -> ShowS
Response fmt -> String
(Int -> Response fmt -> ShowS)
-> (Response fmt -> String)
-> ([Response fmt] -> ShowS)
-> Show (Response fmt)
forall fmt. Show fmt => Int -> Response fmt -> ShowS
forall fmt. Show fmt => [Response fmt] -> ShowS
forall fmt. Show fmt => Response fmt -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Response fmt] -> ShowS
$cshowList :: forall fmt. Show fmt => [Response fmt] -> ShowS
show :: Response fmt -> String
$cshow :: forall fmt. Show fmt => Response fmt -> String
showsPrec :: Int -> Response fmt -> ShowS
$cshowsPrec :: forall fmt. Show fmt => Int -> Response fmt -> ShowS
Show, (forall x. Response fmt -> Rep (Response fmt) x)
-> (forall x. Rep (Response fmt) x -> Response fmt)
-> Generic (Response fmt)
forall x. Rep (Response fmt) x -> Response fmt
forall x. Response fmt -> Rep (Response fmt) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall fmt x. Rep (Response fmt) x -> Response fmt
forall fmt x. Response fmt -> Rep (Response fmt) x
$cto :: forall fmt x. Rep (Response fmt) x -> Response fmt
$cfrom :: forall fmt x. Response fmt -> Rep (Response fmt) x
Generic)