summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Core/PeerAddr.hs
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2013-12-28 12:19:03 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2013-12-28 12:19:03 +0400
commit143f73d83852aa1c676b9bc09d1b624e526ba294 (patch)
treee322795b1f86f367ef7ee96013624939530a4e0c /src/Network/BitTorrent/Core/PeerAddr.hs
parentdcf0f3aef288b5a35c2ff03e98e0b38ce1ac6213 (diff)
Add pretty instances for NodeInfos
Diffstat (limited to 'src/Network/BitTorrent/Core/PeerAddr.hs')
-rw-r--r--src/Network/BitTorrent/Core/PeerAddr.hs18
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
50import Data.Typeable 50import Data.Typeable
51import Data.Word 51import Data.Word
52import Network.Socket 52import Network.Socket
53import Text.PrettyPrint hiding ((<>)) 53import Text.PrettyPrint as PP hiding ((<>))
54import Text.PrettyPrint.Class 54import Text.PrettyPrint.Class
55import Text.Read (readMaybe) 55import Text.Read (readMaybe)
56import qualified Text.ParserCombinators.ReadP as RP 56import 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
89instance 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
167instance Pretty IPv4 where
168 pretty = PP.text . show
169 {-# INLINE pretty #-}
170
171instance Pretty IPv6 where
172 pretty = PP.text . show
173 {-# INLINE pretty #-}
174
175instance Pretty IP where
176 pretty = PP.text . show
177 {-# INLINE pretty #-}
178
163{----------------------------------------------------------------------- 179{-----------------------------------------------------------------------
164-- Peer addr 180-- Peer addr
165-----------------------------------------------------------------------} 181-----------------------------------------------------------------------}