diff options
Diffstat (limited to 'src/Network/BitTorrent/DHT')
-rw-r--r-- | src/Network/BitTorrent/DHT/Token.hs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/Network/BitTorrent/DHT/Token.hs b/src/Network/BitTorrent/DHT/Token.hs index 756b5a98..3da59c53 100644 --- a/src/Network/BitTorrent/DHT/Token.hs +++ b/src/Network/BitTorrent/DHT/Token.hs | |||
@@ -44,6 +44,7 @@ module Network.BitTorrent.DHT.Token | |||
44 | , Network.BitTorrent.DHT.Token.update | 44 | , Network.BitTorrent.DHT.Token.update |
45 | ) where | 45 | ) where |
46 | 46 | ||
47 | import Control.Arrow | ||
47 | import Control.Monad.State | 48 | import Control.Monad.State |
48 | #ifdef VERSION_bencoding | 49 | #ifdef VERSION_bencoding |
49 | import Data.BEncode (BEncode) | 50 | import Data.BEncode (BEncode) |
@@ -75,6 +76,9 @@ newtype Token = Token BS.ByteString | |||
75 | instance Show Token where | 76 | instance Show Token where |
76 | show (Token bs) = B8.unpack $ Base16.encode bs | 77 | show (Token bs) = B8.unpack $ Base16.encode bs |
77 | 78 | ||
79 | instance Read Token where | ||
80 | readsPrec i s = pure $ (Token *** B8.unpack) $ Base16.decode (B8.pack s) | ||
81 | |||
78 | -- | Meaningless token, for testing purposes only. | 82 | -- | Meaningless token, for testing purposes only. |
79 | instance Default Token where | 83 | instance Default Token where |
80 | def = makeToken (0::Int) 0 | 84 | def = makeToken (0::Int) 0 |