From 4de96724e4006589022e08b6ed247784f958b508 Mon Sep 17 00:00:00 2001 From: Sam T Date: Sun, 2 Jun 2013 06:43:00 +0400 Subject: ~ Use pretty package for pretty print. This is a bit faster and pretty! --- src/Network/BitTorrent/PeerWire/Handshake.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/Network/BitTorrent/PeerWire/Handshake.hs') diff --git a/src/Network/BitTorrent/PeerWire/Handshake.hs b/src/Network/BitTorrent/PeerWire/Handshake.hs index 6f4598ae..ff768cae 100644 --- a/src/Network/BitTorrent/PeerWire/Handshake.hs +++ b/src/Network/BitTorrent/PeerWire/Handshake.hs @@ -11,6 +11,7 @@ -- peer. -- {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RecordWildCards #-} module Network.BitTorrent.PeerWire.Handshake ( Handshake(..), handshakeCaps , handshake @@ -27,6 +28,8 @@ import Data.ByteString (ByteString) import qualified Data.ByteString as B import qualified Data.ByteString.Char8 as BC import Data.Serialize as S +import Text.PrettyPrint + import Network import Network.Socket.ByteString @@ -77,9 +80,9 @@ handshakeCaps :: Handshake -> Capabilities handshakeCaps = hsReserved -- | Format handshake in human readable form. -ppHandshake :: Handshake -> String -ppHandshake hs = BC.unpack (hsProtocol hs) ++ " " - ++ ppClientInfo (clientInfo (hsPeerID hs)) +ppHandshake :: Handshake -> Doc +ppHandshake Handshake {..} = + text (BC.unpack hsProtocol) <+> ppClientInfo (clientInfo hsPeerID) -- | Get handshake message size in bytes from the length of protocol string. handshakeSize :: Word8 -> Int -- cgit v1.2.3