diff options
author | joe <joe@jerkface.net> | 2017-09-03 21:11:37 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-09-03 21:11:37 -0400 |
commit | a1a56ca53dc9346365d182b28be0aea7a93c465a (patch) | |
tree | 324dc2333994dfd1166507cd88d968fb2c8e8a2d | |
parent | 287379163d93d58142972f5f94c2beb8e872f7d4 (diff) |
top-level signatures.
-rw-r--r-- | Kademlia.hs | 2 | ||||
-rw-r--r-- | ToxMessage.hs | 4 |
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 | ||
66 | quietInsertions :: InsertionReporter ni | ||
66 | quietInsertions = InsertionReporter | 67 | quietInsertions = InsertionReporter |
67 | { reportArrival = \_ _ _ -> return () | 68 | { reportArrival = \_ _ _ -> return () |
68 | , reportPingResult = \_ _ _ -> return () | 69 | , reportPingResult = \_ _ _ -> return () |
69 | } | 70 | } |
70 | 71 | ||
72 | contramapIR :: (t -> ni) -> InsertionReporter ni -> InsertionReporter t | ||
71 | contramapIR f ir = InsertionReporter | 73 | contramapIR 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 | ||
51 | con_Auth :: Constr | ||
51 | con_Auth = mkConstr (dataTypeOf (Auth (error "con_Auth"))) "Auth" [] Prefix | 52 | con_Auth = mkConstr (dataTypeOf (Auth (error "con_Auth"))) "Auth" [] Prefix |
52 | 53 | ||
53 | instance Serialize Auth where | 54 | instance Serialize Auth where |
@@ -126,6 +127,7 @@ data ImplicitAssymetric = ImplicitAssymetric | |||
126 | } | 127 | } |
127 | deriving (Eq, Ord,Data) | 128 | deriving (Eq, Ord,Data) |
128 | 129 | ||
130 | getRemaining :: Get ByteString | ||
129 | getRemaining = remaining >>= getBytes | 131 | getRemaining = remaining >>= getBytes |
130 | 132 | ||
131 | instance Serialize ImplicitAssymetric where | 133 | instance 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 | ||
413 | getPacket :: Get Packet | ||
411 | getPacket = do | 414 | getPacket = 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 | ||
440 | putPacket :: Packet -> PutM () | ||
437 | putPacket p = do | 441 | putPacket p = do |
438 | put $ pktKind p | 442 | put $ pktKind p |
439 | case pktClass (pktKind p) of | 443 | case pktClass (pktKind p) of |