module Mpv.Data.MpvResources where import Control.Concurrent.STM (TVar) import Control.Concurrent.STM.TBMQueue (TBMQueue) import Network.Socket (Socket) import Mpv.Data.RequestId (RequestId) import Mpv.Data.Response (ResponseError) data InMessage fmt = InMessage { forall fmt. InMessage fmt -> fmt unInMessage :: fmt } | InMessageError { forall fmt. InMessage fmt -> Text error :: Text } deriving stock (InMessage fmt -> InMessage fmt -> Bool (InMessage fmt -> InMessage fmt -> Bool) -> (InMessage fmt -> InMessage fmt -> Bool) -> Eq (InMessage fmt) forall fmt. Eq fmt => InMessage fmt -> InMessage fmt -> Bool forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: InMessage fmt -> InMessage fmt -> Bool $c/= :: forall fmt. Eq fmt => InMessage fmt -> InMessage fmt -> Bool == :: InMessage fmt -> InMessage fmt -> Bool $c== :: forall fmt. Eq fmt => InMessage fmt -> InMessage fmt -> Bool Eq, Int -> InMessage fmt -> ShowS [InMessage fmt] -> ShowS InMessage fmt -> String (Int -> InMessage fmt -> ShowS) -> (InMessage fmt -> String) -> ([InMessage fmt] -> ShowS) -> Show (InMessage fmt) forall fmt. Show fmt => Int -> InMessage fmt -> ShowS forall fmt. Show fmt => [InMessage fmt] -> ShowS forall fmt. Show fmt => InMessage fmt -> String forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [InMessage fmt] -> ShowS $cshowList :: forall fmt. Show fmt => [InMessage fmt] -> ShowS show :: InMessage fmt -> String $cshow :: forall fmt. Show fmt => InMessage fmt -> String showsPrec :: Int -> InMessage fmt -> ShowS $cshowsPrec :: forall fmt. Show fmt => Int -> InMessage fmt -> ShowS Show, (forall x. InMessage fmt -> Rep (InMessage fmt) x) -> (forall x. Rep (InMessage fmt) x -> InMessage fmt) -> Generic (InMessage fmt) forall x. Rep (InMessage fmt) x -> InMessage fmt forall x. InMessage fmt -> Rep (InMessage fmt) x forall a. (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a forall fmt x. Rep (InMessage fmt) x -> InMessage fmt forall fmt x. InMessage fmt -> Rep (InMessage fmt) x $cto :: forall fmt x. Rep (InMessage fmt) x -> InMessage fmt $cfrom :: forall fmt x. InMessage fmt -> Rep (InMessage fmt) x Generic) newtype OutMessage fmt = OutMessage { forall fmt. OutMessage fmt -> fmt unOutMessage :: fmt } deriving stock (OutMessage fmt -> OutMessage fmt -> Bool (OutMessage fmt -> OutMessage fmt -> Bool) -> (OutMessage fmt -> OutMessage fmt -> Bool) -> Eq (OutMessage fmt) forall fmt. Eq fmt => OutMessage fmt -> OutMessage fmt -> Bool forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: OutMessage fmt -> OutMessage fmt -> Bool $c/= :: forall fmt. Eq fmt => OutMessage fmt -> OutMessage fmt -> Bool == :: OutMessage fmt -> OutMessage fmt -> Bool $c== :: forall fmt. Eq fmt => OutMessage fmt -> OutMessage fmt -> Bool Eq, Int -> OutMessage fmt -> ShowS [OutMessage fmt] -> ShowS OutMessage fmt -> String (Int -> OutMessage fmt -> ShowS) -> (OutMessage fmt -> String) -> ([OutMessage fmt] -> ShowS) -> Show (OutMessage fmt) forall fmt. Show fmt => Int -> OutMessage fmt -> ShowS forall fmt. Show fmt => [OutMessage fmt] -> ShowS forall fmt. Show fmt => OutMessage fmt -> String forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [OutMessage fmt] -> ShowS $cshowList :: forall fmt. Show fmt => [OutMessage fmt] -> ShowS show :: OutMessage fmt -> String $cshow :: forall fmt. Show fmt => OutMessage fmt -> String showsPrec :: Int -> OutMessage fmt -> ShowS $cshowsPrec :: forall fmt. Show fmt => Int -> OutMessage fmt -> ShowS Show, (forall x. OutMessage fmt -> Rep (OutMessage fmt) x) -> (forall x. Rep (OutMessage fmt) x -> OutMessage fmt) -> Generic (OutMessage fmt) forall x. Rep (OutMessage fmt) x -> OutMessage fmt forall x. OutMessage fmt -> Rep (OutMessage fmt) x forall a. (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a forall fmt x. Rep (OutMessage fmt) x -> OutMessage fmt forall fmt x. OutMessage fmt -> Rep (OutMessage fmt) x $cto :: forall fmt x. Rep (OutMessage fmt) x -> OutMessage fmt $cfrom :: forall fmt x. OutMessage fmt -> Rep (OutMessage fmt) x Generic) data Requests fmt = Requests { forall fmt. Requests fmt -> RequestId nextId :: RequestId, forall fmt. Requests fmt -> Map RequestId (MVar (Either ResponseError fmt)) pending :: Map RequestId (MVar (Either ResponseError fmt)) } deriving stock (Requests fmt -> Requests fmt -> Bool (Requests fmt -> Requests fmt -> Bool) -> (Requests fmt -> Requests fmt -> Bool) -> Eq (Requests fmt) forall fmt. Requests fmt -> Requests fmt -> Bool forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: Requests fmt -> Requests fmt -> Bool $c/= :: forall fmt. Requests fmt -> Requests fmt -> Bool == :: Requests fmt -> Requests fmt -> Bool $c== :: forall fmt. Requests fmt -> Requests fmt -> Bool Eq) data MpvResources fmt = MpvResources { forall fmt. MpvResources fmt -> Socket socket :: Socket, forall fmt. MpvResources fmt -> TBMQueue (OutMessage fmt) outQueue :: TBMQueue (OutMessage fmt), forall fmt. MpvResources fmt -> TBMQueue (InMessage fmt) inQueue :: TBMQueue (InMessage fmt), forall fmt. MpvResources fmt -> TVar (Requests fmt) requests :: TVar (Requests fmt) }