summaryrefslogtreecommitdiff
path: root/src/Data/Torrent/Client.hs
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2013-11-23 03:37:15 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2013-11-23 03:37:15 +0400
commited25a297094b483dce06e14d52ced2f93f6dca41 (patch)
tree3df60d8b30af29345de021f251903a175e78c70c /src/Data/Torrent/Client.hs
parent708938679954a5d5f9def82e1fa873c19ed662df (diff)
Use pretty-class package
Diffstat (limited to 'src/Data/Torrent/Client.hs')
-rw-r--r--src/Data/Torrent/Client.hs20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/Data/Torrent/Client.hs b/src/Data/Torrent/Client.hs
index f38f7a5c..0fd6722b 100644
--- a/src/Data/Torrent/Client.hs
+++ b/src/Data/Torrent/Client.hs
@@ -22,10 +22,7 @@
22-- 22--
23module Data.Torrent.Client 23module Data.Torrent.Client
24 ( ClientImpl (..) 24 ( ClientImpl (..)
25 , ppClientImpl
26 , ppVersion
27 , ClientInfo (..) 25 , ClientInfo (..)
28 , ppClientInfo
29 , libClientInfo 26 , libClientInfo
30 ) where 27 ) where
31 28
@@ -41,6 +38,7 @@ import Data.String
41import Data.Text as T 38import Data.Text as T
42import Data.Version 39import Data.Version
43import Text.PrettyPrint hiding ((<>)) 40import Text.PrettyPrint hiding ((<>))
41import Text.PrettyPrint.Class
44import Text.Read (readMaybe) 42import Text.Read (readMaybe)
45import Paths_bittorrent (version) 43import Paths_bittorrent (version)
46 44
@@ -125,9 +123,8 @@ instance IsString ClientImpl where
125 alist = L.map mk [minBound..maxBound] 123 alist = L.map mk [minBound..maxBound]
126 mk x = (L.tail $ show x, x) 124 mk x = (L.tail $ show x, x)
127 125
128-- | Format client implementation info in human-readable form. 126instance Pretty ClientImpl where
129ppClientImpl :: ClientImpl -> Doc 127 pretty = text . L.tail . show
130ppClientImpl = text . L.tail . show
131 128
132-- | Just the '0' version. 129-- | Just the '0' version.
133instance Default Version where 130instance Default Version where
@@ -141,9 +138,8 @@ instance IsString Version where
141 where 138 where
142 chunkNums = sequence . L.map readMaybe . L.linesBy ('.' ==) 139 chunkNums = sequence . L.map readMaybe . L.linesBy ('.' ==)
143 140
144-- | Format client implementation version in human-readable form. 141instance Pretty Version where
145ppVersion :: Version -> Doc 142 pretty = text . showVersion
146ppVersion = text . showVersion
147 143
148-- | The all sensible infomation that can be obtained from a peer 144-- | The all sensible infomation that can be obtained from a peer
149-- identifier or torrent /createdBy/ field. 145-- identifier or torrent /createdBy/ field.
@@ -164,10 +160,8 @@ instance IsString ClientInfo where
164 where 160 where
165 (impl, _ver) = L.span ((/=) '-') str 161 (impl, _ver) = L.span ((/=) '-') str
166 162
167-- | Format client info in human-readable form. 163instance Pretty ClientInfo where
168ppClientInfo :: ClientInfo -> Doc 164 pretty ClientInfo {..} = pretty ciImpl <+> "version" <+> pretty ciVersion
169ppClientInfo ClientInfo {..} =
170 ppClientImpl ciImpl <+> "version" <+> ppVersion ciVersion
171 165
172-- | Client info of this (the bittorrent library) package. Normally, 166-- | Client info of this (the bittorrent library) package. Normally,
173-- applications should introduce its own idenitifiers, otherwise they 167-- applications should introduce its own idenitifiers, otherwise they