summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2018-12-10 09:37:14 -0500
committerJoe Crayne <joe@jerkface.net>2018-12-16 14:08:26 -0500
commit739c62c21fad363483c5ec70f1050393bd14964c (patch)
treec226270b1c180c60c266ecdf108b8d1d63f2945e
parent84a594d1f4c5d0d2b276da7063b7888363008e86 (diff)
Show instances for TCP relay handshake.
-rw-r--r--src/Data/Tox/Relay.hs7
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 #-}
7module Data.Tox.Relay where 9module Data.Tox.Relay where
8 10
9import Data.ByteString as B 11import 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.
109newtype Hello (f :: * -> *) = Hello (Asymm (f HelloData)) 111newtype Hello (f :: * -> *) = Hello (Asymm (f HelloData))
110 112
113deriving instance Show (f HelloData) => Show (Hello f)
114
111helloFrom :: Hello f -> PublicKey 115helloFrom :: Hello f -> PublicKey
112helloFrom (Hello x) = senderKey x 116helloFrom (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
144instance Sized HelloData where size = ConstSize 56 149instance 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
161deriving instance Show (f HelloData) => Show (Welcome f)
162
156instance Rank2.Functor Welcome where 163instance Rank2.Functor Welcome where
157 f <$> Welcome n dta = Welcome n (f dta) 164 f <$> Welcome n dta = Welcome n (f dta)
158 165