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} PushMsg : {auto prf : HasState Sender s}
-> Command () Broker Recipient -> 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, 1 + n) <==| s)
(>>> Secured <==> (Secured, n) <==| s) (>>> Secured <==> (Secured, n) <==| s)
Pure : (res : Result a) -> Command a from to state state_fn Pure : (res : Result a) -> Command a from to state state_fn
(>>=) : Command a from1 to1 state1 state2_fn (>>=) : Command a from1 to1 state1 state2_fn
-> ((res : Result a) -> Command b from2 to2 (state2_fn state1 res) state3_fn) -> ((res : Result a) -> Command b from2 to2 (state2_fn state1 res) state3_fn)
-> Command b from1 to2 state1 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 import Protocol
establishConnection : Command () Recipient Recipient establishConnection : Command () Recipient Broker
(Null <==> (Null, 0) <==| Null) (Null <==> (Null, 0) <==| Null)
(>>> Secured <==> (Secured, 0) <==| Secured) (>>> Secured <==> (Secured, 0) <==| Secured)
establishConnection = do establishConnection = do
ids <- CreateConn "recipient's public key for broker" Recipient &> CreateConn "recipient's public key for broker"
Subscribe Recipient &> Subscribe
SendInvite newInvitation Recipient &> SendInvite newInvitation
ConfirmConn "sender's public key for broker" Sender &> ConfirmConn "sender's public key for broker"
PushConfirm Broker &> PushConfirm
SecureConn "sender's public key for broker" Recipient &> SecureConn "sender's public key for broker"
SendWelcome Sender &> SendWelcome
PushWelcome Broker &> PushWelcome
SendMsg "Hello" Sender &> SendMsg "Hello"
PushMsg Broker &> PushMsg
Recipient &> DeleteMsg