diff options
Diffstat (limited to 'src/Data')
-rw-r--r-- | src/Data/Torrent.hs | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/Data/Torrent.hs b/src/Data/Torrent.hs index cfc26453..94506d1c 100644 --- a/src/Data/Torrent.hs +++ b/src/Data/Torrent.hs | |||
@@ -183,7 +183,7 @@ import Network.HTTP.Types.URI | |||
183 | import Network.URI | 183 | import Network.URI |
184 | import Text.ParserCombinators.ReadP as P | 184 | import Text.ParserCombinators.ReadP as P |
185 | import Text.PrettyPrint as PP | 185 | import Text.PrettyPrint as PP |
186 | import Text.PrettyPrint.Class | 186 | import Text.PrettyPrint.HughesPJClass hiding ((<>),($$)) |
187 | import System.FilePath | 187 | import System.FilePath |
188 | import System.Posix.Types | 188 | import System.Posix.Types |
189 | 189 | ||
@@ -247,7 +247,7 @@ instance Show InfoHash where | |||
247 | 247 | ||
248 | -- | Convert to base16 encoded Doc string. | 248 | -- | Convert to base16 encoded Doc string. |
249 | instance Pretty InfoHash where | 249 | instance Pretty InfoHash where |
250 | pretty = text . show | 250 | pPrint = text . show |
251 | 251 | ||
252 | -- | Read base16 encoded string. | 252 | -- | Read base16 encoded string. |
253 | instance Read InfoHash where | 253 | instance Read InfoHash where |
@@ -397,7 +397,7 @@ instance BEncode (FileInfo BS.ByteString) where | |||
397 | {-# INLINE fromBEncode #-} | 397 | {-# INLINE fromBEncode #-} |
398 | 398 | ||
399 | instance Pretty (FileInfo BS.ByteString) where | 399 | instance Pretty (FileInfo BS.ByteString) where |
400 | pretty FileInfo {..} = | 400 | pPrint FileInfo {..} = |
401 | "Path: " <> text (T.unpack (T.decodeUtf8 fiName)) | 401 | "Path: " <> text (T.unpack (T.decodeUtf8 fiName)) |
402 | $$ "Size: " <> text (show fiLength) | 402 | $$ "Size: " <> text (show fiLength) |
403 | $$ maybe PP.empty ppMD5 fiMD5Sum | 403 | $$ maybe PP.empty ppMD5 fiMD5Sum |
@@ -465,8 +465,8 @@ instance BEncode LayoutInfo where | |||
465 | fromBEncode = fromDict getLayoutInfo | 465 | fromBEncode = fromDict getLayoutInfo |
466 | 466 | ||
467 | instance Pretty LayoutInfo where | 467 | instance Pretty LayoutInfo where |
468 | pretty SingleFile {..} = pretty liFile | 468 | pPrint SingleFile {..} = pPrint liFile |
469 | pretty MultiFile {..} = vcat $ L.map (pretty . joinFilePath) liFiles | 469 | pPrint MultiFile {..} = vcat $ L.map (pPrint . joinFilePath) liFiles |
470 | 470 | ||
471 | -- | Test if this is single file torrent. | 471 | -- | Test if this is single file torrent. |
472 | isSingleFile :: LayoutInfo -> Bool | 472 | isSingleFile :: LayoutInfo -> Bool |
@@ -616,7 +616,7 @@ instance NFData (Piece a) | |||
616 | 616 | ||
617 | -- | Payload bytes are omitted. | 617 | -- | Payload bytes are omitted. |
618 | instance Pretty (Piece a) where | 618 | instance Pretty (Piece a) where |
619 | pretty Piece {..} = "Piece" <+> braces ("index" <+> "=" <+> int pieceIndex) | 619 | pPrint Piece {..} = "Piece" <+> braces ("index" <+> "=" <+> int pieceIndex) |
620 | 620 | ||
621 | -- | Get size of piece in bytes. | 621 | -- | Get size of piece in bytes. |
622 | pieceSize :: Piece BL.ByteString -> PieceSize | 622 | pieceSize :: Piece BL.ByteString -> PieceSize |
@@ -685,7 +685,7 @@ instance BEncode PieceInfo where | |||
685 | 685 | ||
686 | -- | Hashes are omitted. | 686 | -- | Hashes are omitted. |
687 | instance Pretty PieceInfo where | 687 | instance Pretty PieceInfo where |
688 | pretty PieceInfo {..} = "Piece size: " <> int piPieceLength | 688 | pPrint PieceInfo {..} = "Piece size: " <> int piPieceLength |
689 | 689 | ||
690 | slice :: Int -> Int -> BS.ByteString -> BS.ByteString | 690 | slice :: Int -> Int -> BS.ByteString -> BS.ByteString |
691 | slice start len = BS.take len . BS.drop start | 691 | slice start len = BS.take len . BS.drop start |
@@ -797,9 +797,9 @@ ppPrivacy privacy = "Privacy: " <> if privacy then "private" else "public" | |||
797 | --ppAdditionalInfo layout = PP.empty | 797 | --ppAdditionalInfo layout = PP.empty |
798 | 798 | ||
799 | instance Pretty InfoDict where | 799 | instance Pretty InfoDict where |
800 | pretty InfoDict {..} = | 800 | pPrint InfoDict {..} = |
801 | pretty idLayoutInfo $$ | 801 | pPrint idLayoutInfo $$ |
802 | pretty idPieceInfo $$ | 802 | pPrint idPieceInfo $$ |
803 | ppPrivacy idPrivate | 803 | ppPrivacy idPrivate |
804 | 804 | ||
805 | {----------------------------------------------------------------------- | 805 | {----------------------------------------------------------------------- |
@@ -930,11 +930,11 @@ _ <:>? Nothing = PP.empty | |||
930 | name <:>? (Just d) = name <:> d | 930 | name <:>? (Just d) = name <:> d |
931 | 931 | ||
932 | instance Pretty Torrent where | 932 | instance Pretty Torrent where |
933 | pretty Torrent {..} = | 933 | pPrint Torrent {..} = |
934 | "InfoHash: " <> pretty (idInfoHash tInfoDict) | 934 | "InfoHash: " <> pPrint (idInfoHash tInfoDict) |
935 | $$ hang "General" 4 generalInfo | 935 | $$ hang "General" 4 generalInfo |
936 | $$ hang "Tracker" 4 trackers | 936 | $$ hang "Tracker" 4 trackers |
937 | $$ pretty tInfoDict | 937 | $$ pPrint tInfoDict |
938 | where | 938 | where |
939 | trackers = case tAnnounceList of | 939 | trackers = case tAnnounceList of |
940 | Nothing -> text (show tAnnounce) | 940 | Nothing -> text (show tAnnounce) |
@@ -1037,7 +1037,7 @@ renderURN URN {..} | |||
1037 | = T.intercalate ":" $ "urn" : urnNamespace ++ [urnString] | 1037 | = T.intercalate ":" $ "urn" : urnNamespace ++ [urnString] |
1038 | 1038 | ||
1039 | instance Pretty URN where | 1039 | instance Pretty URN where |
1040 | pretty = text . T.unpack . renderURN | 1040 | pPrint = text . T.unpack . renderURN |
1041 | 1041 | ||
1042 | instance Show URN where | 1042 | instance Show URN where |
1043 | showsPrec n = showsPrec n . T.unpack . renderURN | 1043 | showsPrec n = showsPrec n . T.unpack . renderURN |
@@ -1260,7 +1260,7 @@ renderMagnetStr :: Magnet -> String | |||
1260 | renderMagnetStr = show . (convert :: Magnet -> URI) | 1260 | renderMagnetStr = show . (convert :: Magnet -> URI) |
1261 | 1261 | ||
1262 | instance Pretty Magnet where | 1262 | instance Pretty Magnet where |
1263 | pretty = PP.text . renderMagnetStr | 1263 | pPrint = PP.text . renderMagnetStr |
1264 | 1264 | ||
1265 | instance Show Magnet where | 1265 | instance Show Magnet where |
1266 | show = renderMagnetStr | 1266 | show = renderMagnetStr |