Skip to content
Snippets Groups Projects
Commit d0b316fe authored by Jens Nolte's avatar Jens Nolte
Browse files

Use type variable `i` for the interface type

parent 7d1e4826
No related branches found
No related tags found
No related merge requests found
...@@ -97,46 +97,46 @@ instance WireFormat "fd" where ...@@ -97,46 +97,46 @@ instance WireFormat "fd" where
-- | A wayland interface -- | A wayland interface
class (Binary (TRequest a), Binary (TEvent a)) => IsInterface a where class (Binary (TRequest i), Binary (TEvent i)) => IsInterface i where
type TRequest a type TRequest i
type TEvent a type TEvent i
interfaceName :: String interfaceName :: String
class IsInterface a => IsObject (s :: Side) a where class IsInterface i => IsObject (s :: Side) i where
type Up s a type Up s i
type Down s a type Down s i
data Side = Client | Server data Side = Client | Server
data Object s m a = IsInterface a => Object ObjectId (Callback s m a) data Object s m i = IsInterface i => Object ObjectId (Callback s m i)
instance IsInterface a => IsObject 'Client a where instance IsInterface i => IsObject 'Client i where
type Up 'Client a = TRequest a type Up 'Client i = TRequest i
type Down 'Client a = TEvent a type Down 'Client i = TEvent i
instance IsInterface a => IsObject 'Server a where instance IsInterface i => IsObject 'Server i where
type Up 'Server a = TEvent a type Up 'Server i = TEvent i
type Down 'Server a = TRequest a type Down 'Server i = TRequest i
instance forall s m a. IsInterface a => IsSomeObject (Object s m a) where instance forall s m i. IsInterface i => IsSomeObject (Object s m i) where
objectId (Object oId _) = oId objectId (Object oId _) = oId
objectInterfaceName _ = interfaceName @a objectInterfaceName _ = interfaceName @i
class IsSomeObject a where class IsSomeObject i where
objectId :: a -> ObjectId objectId :: i -> ObjectId
objectInterfaceName :: a -> String objectInterfaceName :: i -> String
-- | Wayland object quantification wrapper -- | Wayland object quantification wrapper
data SomeObject = forall a. IsSomeObject a => SomeObject a data SomeObject = forall i. IsSomeObject i => SomeObject i
instance IsSomeObject SomeObject where instance IsSomeObject SomeObject where
objectId (SomeObject object) = objectId object objectId (SomeObject object) = objectId object
objectInterfaceName (SomeObject object) = objectInterfaceName object objectInterfaceName (SomeObject object) = objectInterfaceName object
class IsMessage a where class IsMessage i where
messageName :: a -> String messageName :: i -> String
instance IsMessage Void where instance IsMessage Void where
messageName = absurd messageName = absurd
...@@ -187,11 +187,11 @@ data Event = Event ObjectId Opcode (Either BSL.ByteString (Word32, BSL.ByteStrin ...@@ -187,11 +187,11 @@ data Event = Event ObjectId Opcode (Either BSL.ByteString (Word32, BSL.ByteStrin
deriving stock Show deriving stock Show
type ClientCallback m a = Callback 'Client m a type ClientCallback m i = Callback 'Client m i
type ServerCallback m a = Callback 'Server m a type ServerCallback m i = Callback 'Server m i
data Callback s m a = Callback { data Callback s m i = Callback {
messageCallback :: Object s m a -> Down s a -> StateT (ProtocolState s m) m () messageCallback :: Object s m i -> Down s i -> StateT (ProtocolState s m) m ()
} }
-- * Exceptions -- * Exceptions
...@@ -258,7 +258,7 @@ feedInput bytes = protocolStep do ...@@ -258,7 +258,7 @@ feedInput bytes = protocolStep do
inboxDecoder = pushChunk st.inboxDecoder bytes inboxDecoder = pushChunk st.inboxDecoder bytes
} }
sendMessage :: MonadCatch m => Object s m a -> Up s a -> ProtocolStep s m () sendMessage :: MonadCatch m => Object s m i -> Up s i -> ProtocolStep s m ()
sendMessage object message = protocolStep do sendMessage object message = protocolStep do
undefined message undefined message
runCallbacks runCallbacks
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment