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

Move getUp/getDown out of class

parent 47edb0e9
No related branches found
No related tags found
No related merge requests found
...@@ -172,19 +172,14 @@ class ( ...@@ -172,19 +172,14 @@ class (
class IsSide (s :: Side) where class IsSide (s :: Side) where
type Up s i type Up s i
type Down s i type Down s i
getDown :: forall m i. IsInterface i => Object s m i -> Opcode -> Get (Down s i)
instance IsSide 'Client where instance IsSide 'Client where
type Up 'Client i = Request i type Up 'Client i = Request i
type Down 'Client i = Event i type Down 'Client i = Event i
getDown :: forall m i. IsInterface i => Object 'Client m i -> Opcode -> Get (Down 'Client i)
getDown = getMessage @(Down 'Client i)
instance IsSide 'Server where instance IsSide 'Server where
type Up 'Server i = Event i type Up 'Server i = Event i
type Down 'Server i = Request i type Down 'Server i = Request i
getDown :: forall m i. IsInterface i => Object 'Server m i -> Opcode -> Get (Down 'Server i)
getDown = getMessage @(Down 'Server i)
--- | Empty class, used to combine constraints --- | Empty class, used to combine constraints
...@@ -197,6 +192,13 @@ class ( ...@@ -197,6 +192,13 @@ class (
=> IsInterfaceSide (s :: Side) i => IsInterfaceSide (s :: Side) i
getDown :: forall s m i. IsInterfaceSide s i => Object s m i -> Opcode -> Get (Down s i)
getDown = getMessage @(Down s i)
putUp :: forall s i. IsInterfaceSide s i => Up s i -> Put
putUp = putMessage @(Up s i)
class IsInterfaceSide s i => IsInterfaceHandler s m i a where class IsInterfaceSide s i => IsInterfaceHandler s m i a where
handleMessage :: a -> Object s m i -> Down s i -> ProtocolAction s m () handleMessage :: a -> Object s m i -> Down s i -> ProtocolAction s m ()
...@@ -409,7 +411,7 @@ feedInput bytes = protocolStep do ...@@ -409,7 +411,7 @@ feedInput bytes = protocolStep do
inboxDecoder = pushChunk st.inboxDecoder bytes inboxDecoder = pushChunk st.inboxDecoder bytes
} }
sendMessage :: (IsSide s, MonadCatch m) => Object s m i -> Up s i -> ProtocolStep s m () sendMessage :: (IsInterfaceSide s i, 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