Files
simplex-chat/definitions/src/Simplex/Messaging/Client.hs
T
Evgeny Poberezkin bdec751725 Instance template (#33)
* protocol instance template [WIP]

* protocol instances template

* add methods to check correctness of participant types in protocol TH

* PushConfirm and and PushMsg implementation types

* check Command type + doctest
2020-05-14 21:30:37 +01:00

49 lines
1.6 KiB
Haskell

{-# OPTIONS_GHC -fno-warn-unticked-promoted-constructors #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
-- {-# OPTIONS_GHC -ddump-splices #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
module Simplex.Messaging.Client where
import ClassyPrelude
import Simplex.Messaging.Protocol
import Simplex.Messaging.Types
$(protocol Recipient [d|
raCreateConn = CreateConn --> Broker
raSubscribe = Subscribe --> Broker
rcPushConfirm = PushConfirm <-- Broker
rcPushMsg = PushMsg <-- Broker
|])
raCreateConn :: Connection Recipient None Idle
-> CreateConnRequest
-> Either String CreateConnResponse
-> Either String (Connection Recipient New Idle)
raCreateConn = protoActionStub
raSubscribe :: Connection Recipient s Idle
-> ()
-> Either String ()
-> Either String (Connection Recipient s Subscribed)
raSubscribe = protoActionStub
rcPushConfirm :: Connection Recipient Pending Subscribed
-> SecureConnRequest
-> Either String ((), Connection Recipient Confirmed Subscribed)
rcPushConfirm = protoCmdStub
rcPushMsg :: Connection Recipient Secured Subscribed
-> MessagesResponse -- TODO, has to be a single message
-> Either String ((), Connection Recipient Secured Subscribed)
rcPushMsg = protoCmdStub