diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2013-12-28 12:19:03 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2013-12-28 12:19:03 +0400 |
commit | 143f73d83852aa1c676b9bc09d1b624e526ba294 (patch) | |
tree | e322795b1f86f367ef7ee96013624939530a4e0c /src/Network/BitTorrent/Core/PeerAddr.hs | |
parent | dcf0f3aef288b5a35c2ff03e98e0b38ce1ac6213 (diff) |
Add pretty instances for NodeInfos
Diffstat (limited to 'src/Network/BitTorrent/Core/PeerAddr.hs')
-rw-r--r-- | src/Network/BitTorrent/Core/PeerAddr.hs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/Network/BitTorrent/Core/PeerAddr.hs b/src/Network/BitTorrent/Core/PeerAddr.hs index 9f5c7c5d..4905f910 100644 --- a/src/Network/BitTorrent/Core/PeerAddr.hs +++ b/src/Network/BitTorrent/Core/PeerAddr.hs | |||
@@ -50,7 +50,7 @@ import Data.String | |||
50 | import Data.Typeable | 50 | import Data.Typeable |
51 | import Data.Word | 51 | import Data.Word |
52 | import Network.Socket | 52 | import Network.Socket |
53 | import Text.PrettyPrint hiding ((<>)) | 53 | import Text.PrettyPrint as PP hiding ((<>)) |
54 | import Text.PrettyPrint.Class | 54 | import Text.PrettyPrint.Class |
55 | import Text.Read (readMaybe) | 55 | import Text.Read (readMaybe) |
56 | import qualified Text.ParserCombinators.ReadP as RP | 56 | import qualified Text.ParserCombinators.ReadP as RP |
@@ -86,6 +86,10 @@ instance Hashable PortNumber where | |||
86 | hashWithSalt s = hashWithSalt s . fromEnum | 86 | hashWithSalt s = hashWithSalt s . fromEnum |
87 | {-# INLINE hashWithSalt #-} | 87 | {-# INLINE hashWithSalt #-} |
88 | 88 | ||
89 | instance Pretty PortNumber where | ||
90 | pretty = PP.int . fromEnum | ||
91 | {-# INLINE pretty #-} | ||
92 | |||
89 | {----------------------------------------------------------------------- | 93 | {----------------------------------------------------------------------- |
90 | -- IP addr | 94 | -- IP addr |
91 | -----------------------------------------------------------------------} | 95 | -----------------------------------------------------------------------} |
@@ -160,6 +164,18 @@ instance Serialize IPv6 where | |||
160 | put ip = put $ toHostAddress6 ip | 164 | put ip = put $ toHostAddress6 ip |
161 | get = fromHostAddress6 <$> get | 165 | get = fromHostAddress6 <$> get |
162 | 166 | ||
167 | instance Pretty IPv4 where | ||
168 | pretty = PP.text . show | ||
169 | {-# INLINE pretty #-} | ||
170 | |||
171 | instance Pretty IPv6 where | ||
172 | pretty = PP.text . show | ||
173 | {-# INLINE pretty #-} | ||
174 | |||
175 | instance Pretty IP where | ||
176 | pretty = PP.text . show | ||
177 | {-# INLINE pretty #-} | ||
178 | |||
163 | {----------------------------------------------------------------------- | 179 | {----------------------------------------------------------------------- |
164 | -- Peer addr | 180 | -- Peer addr |
165 | -----------------------------------------------------------------------} | 181 | -----------------------------------------------------------------------} |