diff --git a/typed-protocols/src/Network/TypedProtocol/Core.hs b/typed-protocols/src/Network/TypedProtocol/Core.hs index 8e937e287bb..ec260da8554 100644 --- a/typed-protocols/src/Network/TypedProtocol/Core.hs +++ b/typed-protocols/src/Network/TypedProtocol/Core.hs @@ -1,5 +1,6 @@ {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE GADTs #-} +{-# LANGUAGE KindSignatures #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE PolyKinds #-} @@ -26,6 +27,7 @@ module Network.TypedProtocol.Core ( -- * Engaging in protocols -- $using PeerRole(..), + TokPeerRole(..), FlipAgency, PeerHasAgency(..), WeHaveAgency, @@ -320,6 +322,14 @@ class Protocol ps where -- data PeerRole = AsClient | AsServer +-- | Singletons for the promoted 'PeerRole' types. Not directly used by the +-- framework, however some times useful when writing code that is shared between +-- client and server. +-- +data TokPeerRole (peerRole :: PeerRole) where + TokAsClient :: TokPeerRole AsClient + TokAsServer :: TokPeerRole AsServer + -- | This data type is used to hold state tokens for states with either client -- or server agency. This GADT shows up when writing protocol peers, when -- 'Yield'ing or 'Await'ing, and when writing message encoders\/decoders.