summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2017-09-03 21:11:37 -0400
committerjoe <joe@jerkface.net>2017-09-03 21:11:37 -0400
commita1a56ca53dc9346365d182b28be0aea7a93c465a (patch)
tree324dc2333994dfd1166507cd88d968fb2c8e8a2d
parent287379163d93d58142972f5f94c2beb8e872f7d4 (diff)
top-level signatures.
-rw-r--r--Kademlia.hs2
-rw-r--r--ToxMessage.hs4
2 files changed, 6 insertions, 0 deletions
diff --git a/Kademlia.hs b/Kademlia.hs
index f256366f..f2288642 100644
--- a/Kademlia.hs
+++ b/Kademlia.hs
@@ -63,11 +63,13 @@ data InsertionReporter ni = InsertionReporter
63 -> IO () 63 -> IO ()
64 } 64 }
65 65
66quietInsertions :: InsertionReporter ni
66quietInsertions = InsertionReporter 67quietInsertions = InsertionReporter
67 { reportArrival = \_ _ _ -> return () 68 { reportArrival = \_ _ _ -> return ()
68 , reportPingResult = \_ _ _ -> return () 69 , reportPingResult = \_ _ _ -> return ()
69 } 70 }
70 71
72contramapIR :: (t -> ni) -> InsertionReporter ni -> InsertionReporter t
71contramapIR f ir = InsertionReporter 73contramapIR f ir = InsertionReporter
72 { reportArrival = \tm ni nis -> reportArrival ir tm (f ni) (map f nis) 74 { reportArrival = \tm ni nis -> reportArrival ir tm (f ni) (map f nis)
73 , reportPingResult = \tm ni b -> reportPingResult ir tm (f ni) b 75 , reportPingResult = \tm ni b -> reportPingResult ir tm (f ni) b
diff --git a/ToxMessage.hs b/ToxMessage.hs
index 9a896c52..41204697 100644
--- a/ToxMessage.hs
+++ b/ToxMessage.hs
@@ -48,6 +48,7 @@ instance Data Auth where
48 48
49 dataTypeOf _ = mkDataType "ToxMessage" [con_Auth] 49 dataTypeOf _ = mkDataType "ToxMessage" [con_Auth]
50 50
51con_Auth :: Constr
51con_Auth = mkConstr (dataTypeOf (Auth (error "con_Auth"))) "Auth" [] Prefix 52con_Auth = mkConstr (dataTypeOf (Auth (error "con_Auth"))) "Auth" [] Prefix
52 53
53instance Serialize Auth where 54instance Serialize Auth where
@@ -126,6 +127,7 @@ data ImplicitAssymetric = ImplicitAssymetric
126 } 127 }
127 deriving (Eq, Ord,Data) 128 deriving (Eq, Ord,Data)
128 129
130getRemaining :: Get ByteString
129getRemaining = remaining >>= getBytes 131getRemaining = remaining >>= getBytes
130 132
131instance Serialize ImplicitAssymetric where 133instance Serialize ImplicitAssymetric where
@@ -408,6 +410,7 @@ instance Serialize Packet where
408 get = getPacket 410 get = getPacket
409 put = putPacket 411 put = putPacket
410 412
413getPacket :: Get Packet
411getPacket = do 414getPacket = do
412 typ <- get 415 typ <- get
413 case pktClass typ of 416 case pktClass typ of
@@ -434,6 +437,7 @@ getPacket = do
434 NoncedUnclaimedClass toPacket _ -> toPacket <$> get <*> get 437 NoncedUnclaimedClass toPacket _ -> toPacket <$> get <*> get
435 Unclassified -> fail $ "todo: unserialize packet "++show typ 438 Unclassified -> fail $ "todo: unserialize packet "++show typ
436 439
440putPacket :: Packet -> PutM ()
437putPacket p = do 441putPacket p = do
438 put $ pktKind p 442 put $ pktKind p
439 case pktClass (pktKind p) of 443 case pktClass (pktKind p) of