diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2013-11-23 02:14:13 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2013-11-23 02:14:13 +0400 |
commit | 41f229b5746501738800d721fb19083e32516f8c (patch) | |
tree | 8a469cf08a3d5d377fb8679bba759393cc7d8ef2 /src/Data/Torrent | |
parent | 923abc9ee7576f2d3e1b7e2b2d5a32ed5d2f21c9 (diff) |
Remove ClientVersion newtype
Diffstat (limited to 'src/Data/Torrent')
-rw-r--r-- | src/Data/Torrent/Client.hs | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/src/Data/Torrent/Client.hs b/src/Data/Torrent/Client.hs index 0246e29a..a7e94513 100644 --- a/src/Data/Torrent/Client.hs +++ b/src/Data/Torrent/Client.hs | |||
@@ -21,15 +21,9 @@ | |||
21 | -- done using 'Network.BitTorrent.Extension'! | 21 | -- done using 'Network.BitTorrent.Extension'! |
22 | -- | 22 | -- |
23 | module Data.Torrent.Client | 23 | module Data.Torrent.Client |
24 | ( -- * Client implementation | 24 | ( ClientImpl (..) |
25 | ClientImpl (..) | ||
26 | , ppClientImpl | 25 | , ppClientImpl |
27 | 26 | , ppVersion | |
28 | -- * Client version | ||
29 | , ClientVersion (..) | ||
30 | , ppClientVersion | ||
31 | |||
32 | -- * Client information | ||
33 | , ClientInfo (..) | 27 | , ClientInfo (..) |
34 | , ppClientInfo | 28 | , ppClientInfo |
35 | , libClientInfo | 29 | , libClientInfo |
@@ -122,23 +116,19 @@ instance Default ClientImpl where | |||
122 | ppClientImpl :: ClientImpl -> Doc | 116 | ppClientImpl :: ClientImpl -> Doc |
123 | ppClientImpl = text . L.tail . show | 117 | ppClientImpl = text . L.tail . show |
124 | 118 | ||
125 | -- | Version of client software, normally extracted from peer id. | ||
126 | newtype ClientVersion = ClientVersion { getClientVersion :: Version } | ||
127 | deriving (Show, Eq, Ord) | ||
128 | |||
129 | -- | Just the '0' version. | 119 | -- | Just the '0' version. |
130 | instance Default ClientVersion where | 120 | instance Default Version where |
131 | def = ClientVersion $ Version [0] [] | 121 | def = Version [0] [] |
132 | 122 | ||
133 | -- | Format client implementation version in human-readable form. | 123 | -- | Format client implementation version in human-readable form. |
134 | ppClientVersion :: ClientVersion -> Doc | 124 | ppVersion :: Version -> Doc |
135 | ppClientVersion = text . showVersion . getClientVersion | 125 | ppVersion = text . showVersion |
136 | 126 | ||
137 | -- | The all sensible infomation that can be obtained from a peer | 127 | -- | The all sensible infomation that can be obtained from a peer |
138 | -- identifier or torrent /createdBy/ field. | 128 | -- identifier or torrent /createdBy/ field. |
139 | data ClientInfo = ClientInfo { | 129 | data ClientInfo = ClientInfo { |
140 | ciImpl :: ClientImpl | 130 | ciImpl :: ClientImpl |
141 | , ciVersion :: ClientVersion | 131 | , ciVersion :: Version |
142 | } deriving (Show, Eq, Ord) | 132 | } deriving (Show, Eq, Ord) |
143 | 133 | ||
144 | -- | Unrecognized client implementation. | 134 | -- | Unrecognized client implementation. |
@@ -148,14 +138,14 @@ instance Default ClientInfo where | |||
148 | -- | Format client info in human-readable form. | 138 | -- | Format client info in human-readable form. |
149 | ppClientInfo :: ClientInfo -> Doc | 139 | ppClientInfo :: ClientInfo -> Doc |
150 | ppClientInfo ClientInfo {..} = | 140 | ppClientInfo ClientInfo {..} = |
151 | ppClientImpl ciImpl <+> "version" <+> ppClientVersion ciVersion | 141 | ppClientImpl ciImpl <+> "version" <+> ppVersion ciVersion |
152 | 142 | ||
153 | -- | Client info of this (the bittorrent library) package. Normally, | 143 | -- | Client info of this (the bittorrent library) package. Normally, |
154 | -- applications should introduce its own idenitifiers, otherwise they | 144 | -- applications should introduce its own idenitifiers, otherwise they |
155 | -- can use 'libClientInfo' value. | 145 | -- can use 'libClientInfo' value. |
156 | -- | 146 | -- |
157 | libClientInfo :: ClientInfo | 147 | libClientInfo :: ClientInfo |
158 | libClientInfo = ClientInfo IlibHSbittorrent (ClientVersion version) | 148 | libClientInfo = ClientInfo IlibHSbittorrent version |
159 | 149 | ||
160 | {----------------------------------------------------------------------- | 150 | {----------------------------------------------------------------------- |
161 | -- For torrent file | 151 | -- For torrent file |
@@ -164,7 +154,7 @@ libClientInfo = ClientInfo IlibHSbittorrent (ClientVersion version) | |||
164 | renderImpl :: ClientImpl -> Text | 154 | renderImpl :: ClientImpl -> Text |
165 | renderImpl = T.pack . L.tail . show | 155 | renderImpl = T.pack . L.tail . show |
166 | 156 | ||
167 | renderVersion :: ClientVersion -> Text | 157 | renderVersion :: Version -> Text |
168 | renderVersion = undefined | 158 | renderVersion = undefined |
169 | 159 | ||
170 | renderClientInfo :: ClientInfo -> Text | 160 | renderClientInfo :: ClientInfo -> Text |