diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2014-02-16 19:40:55 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2014-02-16 19:40:55 +0400 |
commit | 74d06faeb4dee931eea575f19481019f11179bde (patch) | |
tree | d0d806df46b8eb62359253cb7ba479ee3e4a1b06 /src/Network/BitTorrent/Core/NodeInfo.hs | |
parent | 230012ff6108b012c6a8ed2e62f1deb8776f7a97 (diff) |
Add functor instance for NodeInfo
Diffstat (limited to 'src/Network/BitTorrent/Core/NodeInfo.hs')
-rw-r--r-- | src/Network/BitTorrent/Core/NodeInfo.hs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Network/BitTorrent/Core/NodeInfo.hs b/src/Network/BitTorrent/Core/NodeInfo.hs index 2fd7e575..fa20caf5 100644 --- a/src/Network/BitTorrent/Core/NodeInfo.hs +++ b/src/Network/BitTorrent/Core/NodeInfo.hs | |||
@@ -19,6 +19,7 @@ | |||
19 | {-# LANGUAGE TemplateHaskell #-} | 19 | {-# LANGUAGE TemplateHaskell #-} |
20 | {-# LANGUAGE GeneralizedNewtypeDeriving #-} | 20 | {-# LANGUAGE GeneralizedNewtypeDeriving #-} |
21 | {-# LANGUAGE DeriveDataTypeable #-} | 21 | {-# LANGUAGE DeriveDataTypeable #-} |
22 | {-# LANGUAGE DeriveFunctor #-} | ||
22 | module Network.BitTorrent.Core.NodeInfo | 23 | module Network.BitTorrent.Core.NodeInfo |
23 | ( -- * Node ID | 24 | ( -- * Node ID |
24 | NodeId | 25 | NodeId |
@@ -143,7 +144,7 @@ distance (NodeId a) (NodeId b) = NodeDistance (BS.pack (BS.zipWith xor a b)) | |||
143 | data NodeAddr a = NodeAddr | 144 | data NodeAddr a = NodeAddr |
144 | { nodeHost :: !a | 145 | { nodeHost :: !a |
145 | , nodePort :: {-# UNPACK #-} !PortNumber | 146 | , nodePort :: {-# UNPACK #-} !PortNumber |
146 | } deriving (Eq, Typeable) | 147 | } deriving (Eq, Typeable, Functor) |
147 | 148 | ||
148 | $(deriveJSON omitRecordPrefix ''NodeAddr) | 149 | $(deriveJSON omitRecordPrefix ''NodeAddr) |
149 | 150 | ||
@@ -199,7 +200,7 @@ fromPeerAddr PeerAddr {..} = NodeAddr | |||
199 | data NodeInfo a = NodeInfo | 200 | data NodeInfo a = NodeInfo |
200 | { nodeId :: !NodeId | 201 | { nodeId :: !NodeId |
201 | , nodeAddr :: !(NodeAddr a) | 202 | , nodeAddr :: !(NodeAddr a) |
202 | } deriving (Show, Eq) | 203 | } deriving (Show, Eq, Functor) |
203 | 204 | ||
204 | $(deriveJSON omitRecordPrefix ''NodeInfo) | 205 | $(deriveJSON omitRecordPrefix ''NodeInfo) |
205 | 206 | ||