diff options
author | Joe Crayne <joe@jerkface.net> | 2018-12-10 09:37:14 -0500 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2018-12-16 14:08:26 -0500 |
commit | 739c62c21fad363483c5ec70f1050393bd14964c (patch) | |
tree | c226270b1c180c60c266ecdf108b8d1d63f2945e | |
parent | 84a594d1f4c5d0d2b276da7063b7888363008e86 (diff) |
Show instances for TCP relay handshake.
-rw-r--r-- | src/Data/Tox/Relay.hs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Data/Tox/Relay.hs b/src/Data/Tox/Relay.hs index 1fe6d256..02300866 100644 --- a/src/Data/Tox/Relay.hs +++ b/src/Data/Tox/Relay.hs | |||
@@ -4,6 +4,8 @@ | |||
4 | {-# LANGUAGE GeneralizedNewtypeDeriving #-} | 4 | {-# LANGUAGE GeneralizedNewtypeDeriving #-} |
5 | {-# LANGUAGE KindSignatures #-} | 5 | {-# LANGUAGE KindSignatures #-} |
6 | {-# LANGUAGE MultiParamTypeClasses #-} | 6 | {-# LANGUAGE MultiParamTypeClasses #-} |
7 | {-# LANGUAGE StandaloneDeriving #-} | ||
8 | {-# LANGUAGE UndecidableInstances #-} | ||
7 | module Data.Tox.Relay where | 9 | module Data.Tox.Relay where |
8 | 10 | ||
9 | import Data.ByteString as B | 11 | import Data.ByteString as B |
@@ -108,6 +110,8 @@ instance Serialize RelayPacket where | |||
108 | -- | Initial client-to-server handshake message. | 110 | -- | Initial client-to-server handshake message. |
109 | newtype Hello (f :: * -> *) = Hello (Asymm (f HelloData)) | 111 | newtype Hello (f :: * -> *) = Hello (Asymm (f HelloData)) |
110 | 112 | ||
113 | deriving instance Show (f HelloData) => Show (Hello f) | ||
114 | |||
111 | helloFrom :: Hello f -> PublicKey | 115 | helloFrom :: Hello f -> PublicKey |
112 | helloFrom (Hello x) = senderKey x | 116 | helloFrom (Hello x) = senderKey x |
113 | 117 | ||
@@ -140,6 +144,7 @@ data HelloData = HelloData | |||
140 | { sessionPublicKey :: PublicKey | 144 | { sessionPublicKey :: PublicKey |
141 | , sessionBaseNonce :: Nonce24 | 145 | , sessionBaseNonce :: Nonce24 |
142 | } | 146 | } |
147 | deriving Show | ||
143 | 148 | ||
144 | instance Sized HelloData where size = ConstSize 56 | 149 | instance Sized HelloData where size = ConstSize 56 |
145 | 150 | ||
@@ -153,6 +158,8 @@ data Welcome (f :: * -> *) = Welcome | |||
153 | , welcomeData :: f HelloData | 158 | , welcomeData :: f HelloData |
154 | } | 159 | } |
155 | 160 | ||
161 | deriving instance Show (f HelloData) => Show (Welcome f) | ||
162 | |||
156 | instance Rank2.Functor Welcome where | 163 | instance Rank2.Functor Welcome where |
157 | f <$> Welcome n dta = Welcome n (f dta) | 164 | f <$> Welcome n dta = Welcome n (f dta) |
158 | 165 | ||