From ed25a297094b483dce06e14d52ced2f93f6dca41 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Sat, 23 Nov 2013 03:37:15 +0400 Subject: Use pretty-class package --- src/Data/Torrent/Piece.hs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/Data/Torrent/Piece.hs') diff --git a/src/Data/Torrent/Piece.hs b/src/Data/Torrent/Piece.hs index c8727a65..6cff53d6 100644 --- a/src/Data/Torrent/Piece.hs +++ b/src/Data/Torrent/Piece.hs @@ -21,13 +21,11 @@ module Data.Torrent.Piece -- * Piece data , Piece (..) - , ppPiece , pieceSize , isPiece -- * Piece control , PieceInfo (..) - , ppPieceInfo , pieceCount -- * Lens @@ -61,6 +59,7 @@ import Data.List as L import Data.Text.Encoding as T import Data.Typeable import Text.PrettyPrint +import Text.PrettyPrint.Class import Data.Torrent.Block @@ -121,10 +120,9 @@ $(deriveJSON (L.map toLower . L.dropWhile isLower) ''Piece) instance NFData (Piece a) --- | Format piece in human readable form. Payload bytes are omitted. -ppPiece :: Piece a -> Doc -ppPiece Piece {..} - = "Piece" <+> braces ("index" <+> "=" <+> int pieceIndex) +-- | Payload bytes are omitted. +instance Pretty (Piece a) where + pretty Piece {..} = "Piece" <+> braces ("index" <+> "=" <+> int pieceIndex) -- | Get size of piece in bytes. pieceSize :: Piece BL.ByteString -> PieceSize @@ -192,10 +190,9 @@ instance BEncode PieceInfo where toBEncode = toDict . (`putPieceInfo` endDict) fromBEncode = fromDict getPieceInfo --- | Format piece info in human readable form. Hashes are omitted. -ppPieceInfo :: PieceInfo -> Doc -ppPieceInfo PieceInfo {..} = - "Piece size: " <> int piPieceLength +-- | Hashes are omitted. +instance Pretty PieceInfo where + pretty PieceInfo {..} = "Piece size: " <> int piPieceLength hashsize :: Int hashsize = 20 -- cgit v1.2.3