all parties have resource state of the same kind

This commit is contained in:
Evgeny Poberezkin
2020-07-12 09:45:55 +01:00
parent cf3afbac8a
commit 2b07f80828
8 changed files with 74 additions and 131 deletions
+8 -9
View File
@@ -11,20 +11,19 @@
module Simplex.Messaging.Client where
import Control.Monad.Trans.Except
import Control.Protocol (PartyCmd (..))
import Polysemy.Internal
import Simplex.Messaging.Protocol
instance Monad m => PartyProtocol m Recipient where
api ::
SimplexCommand from (Cmd Recipient s s') a ->
SimplexCommand from '(Recipient, s, s') a ->
Connection Recipient s ->
ExceptT String m (a, Connection Recipient s')
api (PushConfirm _ _) = apiStub
api (PushMsg _ _) = apiStub
action ::
SimplexCommand (Cmd Recipient s s') to a ->
SimplexCommand '(Recipient, s, s') to a ->
Connection Recipient s ->
ExceptT String m a ->
ExceptT String m (Connection Recipient s')
@@ -37,13 +36,13 @@ instance Monad m => PartyProtocol m Recipient where
instance Monad m => PartyProtocol m Sender where
api ::
SimplexCommand from (Cmd Sender s s') a ->
SimplexCommand from '(Sender, s, s') a ->
Connection Sender s ->
ExceptT String m (a, Connection Sender s')
api (SendInvite _) = apiStub
action ::
SimplexCommand (Cmd Sender s s') to a ->
SimplexCommand '(Sender, s, s') to a ->
Connection Sender s ->
ExceptT String m a ->
ExceptT String m (Connection Sender s')
@@ -56,14 +55,14 @@ type SimplexSender = SimplexParty Sender
rApi ::
Member SimplexRecipient r =>
SimplexCommand from (Cmd Recipient s s') a ->
SimplexCommand from '(Recipient, s, s') a ->
Connection Recipient s ->
Sem r (Either String (a, Connection Recipient s'))
rApi cmd conn = send $ Api cmd conn
rAction ::
Member SimplexRecipient r =>
SimplexCommand (Cmd Recipient s s') to a ->
SimplexCommand '(Recipient, s, s') to a ->
Connection Recipient s ->
Either String a ->
Sem r (Either String (Connection Recipient s'))
@@ -71,14 +70,14 @@ rAction cmd conn res = send $ Action cmd conn res
sApi ::
Member SimplexSender r =>
SimplexCommand from (Cmd Sender s s') a ->
SimplexCommand from '(Sender, s, s') a ->
Connection Sender s ->
Sem r (Either String (a, Connection Sender s'))
sApi cmd conn = send $ Api cmd conn
sAction ::
Member SimplexSender r =>
SimplexCommand (Cmd Sender s s') to a ->
SimplexCommand '(Sender, s, s') to a ->
Connection Sender s ->
Either String a ->
Sem r (Either String (Connection Sender s'))