add type-verified command actor (from)

This commit is contained in:
Evgeny Poberezkin 2020-05-08 13:33:54 +01:00
parent 222051fc5d
commit b64a2e615d
2 changed files with 26 additions and 11 deletions

View file

@ -274,10 +274,24 @@ data Command : (ty : Type)
PushMsg : {auto prf : HasState Sender s}
-> Command () Broker Recipient
(Secured <==> (Secured, n) <==| s)
(>>> Secured <==> (Secured, n) <==| s)
DeleteMsg : {auto prf : HasState Sender s}
-> Command () Recipient Broker
(Secured <==> (Secured, 1 + n) <==| s)
(>>> Secured <==> (Secured, n) <==| s)
Pure : (res : Result a) -> Command a from to state state_fn
(>>=) : Command a from1 to1 state1 state2_fn
-> ((res : Result a) -> Command b from2 to2 (state2_fn state1 res) state3_fn)
-> Command b from1 to2 state1 state3_fn
infix 5 &>
(&>) : (p : Participant)
-> Command a from1 to1 state1 state2_fn
-> {auto prf : p = from1}
-> Command a from1 to1 state1 state2_fn
(&>) _ c = c

View file

@ -2,17 +2,18 @@ module Simplex.Messaging.Scenarios
import Protocol
establishConnection : Command () Recipient Recipient
establishConnection : Command () Recipient Broker
(Null <==> (Null, 0) <==| Null)
(>>> Secured <==> (Secured, 0) <==| Secured)
establishConnection = do
ids <- CreateConn "recipient's public key for broker"
Subscribe
SendInvite newInvitation
ConfirmConn "sender's public key for broker"
PushConfirm
SecureConn "sender's public key for broker"
SendWelcome
PushWelcome
SendMsg "Hello"
PushMsg
Recipient &> CreateConn "recipient's public key for broker"
Recipient &> Subscribe
Recipient &> SendInvite newInvitation
Sender &> ConfirmConn "sender's public key for broker"
Broker &> PushConfirm
Recipient &> SecureConn "sender's public key for broker"
Sender &> SendWelcome
Broker &> PushWelcome
Sender &> SendMsg "Hello"
Broker &> PushMsg
Recipient &> DeleteMsg