diff options
Diffstat (limited to 'src/Data/Torrent/Client.hs')
-rw-r--r-- | src/Data/Torrent/Client.hs | 20 |
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 | -- |
23 | module Data.Torrent.Client | 23 | module 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 | |||
41 | import Data.Text as T | 38 | import Data.Text as T |
42 | import Data.Version | 39 | import Data.Version |
43 | import Text.PrettyPrint hiding ((<>)) | 40 | import Text.PrettyPrint hiding ((<>)) |
41 | import Text.PrettyPrint.Class | ||
44 | import Text.Read (readMaybe) | 42 | import Text.Read (readMaybe) |
45 | import Paths_bittorrent (version) | 43 | import 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. | 126 | instance Pretty ClientImpl where |
129 | ppClientImpl :: ClientImpl -> Doc | 127 | pretty = text . L.tail . show |
130 | ppClientImpl = text . L.tail . show | ||
131 | 128 | ||
132 | -- | Just the '0' version. | 129 | -- | Just the '0' version. |
133 | instance Default Version where | 130 | instance 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. | 141 | instance Pretty Version where |
145 | ppVersion :: Version -> Doc | 142 | pretty = text . showVersion |
146 | ppVersion = 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. | 163 | instance Pretty ClientInfo where |
168 | ppClientInfo :: ClientInfo -> Doc | 164 | pretty ClientInfo {..} = pretty ciImpl <+> "version" <+> pretty ciVersion |
169 | ppClientInfo 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 |