From daf12c123f28ae52726cb708b319e7f11f857214 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Wed, 8 Jan 2014 08:36:22 +0400 Subject: Prettify instance Show PeerAddr --- src/Network/BitTorrent/Core/Node.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/Network/BitTorrent/Core') diff --git a/src/Network/BitTorrent/Core/Node.hs b/src/Network/BitTorrent/Core/Node.hs index 116333c5..82f05de4 100644 --- a/src/Network/BitTorrent/Core/Node.hs +++ b/src/Network/BitTorrent/Core/Node.hs @@ -118,10 +118,14 @@ genNodeId = NodeId <$> getEntropy nodeIdSize data NodeAddr a = NodeAddr { nodeHost :: !a , nodePort :: {-# UNPACK #-} !PortNumber - } deriving (Show, Eq, Typeable) + } deriving (Eq, Typeable) $(deriveJSON omitRecordPrefix ''NodeAddr) +instance Show a => Show (NodeAddr a) where + showsPrec i NodeAddr {..} + = showsPrec i nodeHost <> showString ":" <> showsPrec i nodePort + instance Read (NodeAddr IPv4) where readsPrec i x = [ (fromPeerAddr a, s) | (a, s) <- readsPrec i x ] -- cgit v1.2.3