diff options
author | Sam T <pxqr.sta@gmail.com> | 2013-07-21 00:48:19 +0400 |
---|---|---|
committer | Sam T <pxqr.sta@gmail.com> | 2013-07-21 00:48:19 +0400 |
commit | 9101056298bbbd891b6134c45b63146c2b2125e2 (patch) | |
tree | 8bace6ba2831f6e1448bae50dba8bf0b0dccf12a /src/Data | |
parent | 8fe68502f23cd737cfd198ce63ae8522c8e11a7f (diff) |
+ Add JSON instances for Tracker info.
Diffstat (limited to 'src/Data')
-rw-r--r-- | src/Data/Torrent.hs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/Data/Torrent.hs b/src/Data/Torrent.hs index a1df0034..1dab1541 100644 --- a/src/Data/Torrent.hs +++ b/src/Data/Torrent.hs | |||
@@ -16,13 +16,14 @@ | |||
16 | -- <http://www.bittorrent.org/beps/bep_0003.html#metainfo-files>, | 16 | -- <http://www.bittorrent.org/beps/bep_0003.html#metainfo-files>, |
17 | -- <https://wiki.theory.org/BitTorrentSpecification#Metainfo_File_Structure> | 17 | -- <https://wiki.theory.org/BitTorrentSpecification#Metainfo_File_Structure> |
18 | -- | 18 | -- |
19 | {-# OPTIONS -fno-warn-orphans #-} | 19 | {-# LANGUAGE OverloadedStrings #-} |
20 | {-# LANGUAGE CPP #-} | 20 | {-# LANGUAGE RecordWildCards #-} |
21 | {-# LANGUAGE FlexibleInstances #-} | 21 | {-# LANGUAGE CPP #-} |
22 | {-# LANGUAGE OverloadedStrings #-} | 22 | {-# LANGUAGE FlexibleInstances #-} |
23 | {-# LANGUAGE RecordWildCards #-} | 23 | {-# LANGUAGE BangPatterns #-} |
24 | {-# LANGUAGE BangPatterns #-} | 24 | {-# LANGUAGE GeneralizedNewtypeDeriving #-} |
25 | {-# LANGUAGE TemplateHaskell #-} | 25 | {-# LANGUAGE TemplateHaskell #-} |
26 | {-# OPTIONS -fno-warn-orphans #-} | ||
26 | -- TODO refine interface | 27 | -- TODO refine interface |
27 | module Data.Torrent | 28 | module Data.Torrent |
28 | ( -- * Torrent | 29 | ( -- * Torrent |
@@ -69,6 +70,7 @@ import Control.Monad | |||
69 | 70 | ||
70 | import qualified Crypto.Hash.SHA1 as C | 71 | import qualified Crypto.Hash.SHA1 as C |
71 | 72 | ||
73 | import Data.Aeson | ||
72 | import Data.Aeson.TH | 74 | import Data.Aeson.TH |
73 | import Data.BEncode as BE | 75 | import Data.BEncode as BE |
74 | import Data.Char | 76 | import Data.Char |
@@ -98,7 +100,7 @@ import Numeric | |||
98 | 100 | ||
99 | -- | Exactly 20 bytes long SHA1 hash of the info part of torrent file. | 101 | -- | Exactly 20 bytes long SHA1 hash of the info part of torrent file. |
100 | newtype InfoHash = InfoHash { getInfoHash :: ByteString } | 102 | newtype InfoHash = InfoHash { getInfoHash :: ByteString } |
101 | deriving (Eq, Ord) | 103 | deriving (Eq, Ord, ToJSON, FromJSON) |
102 | 104 | ||
103 | instance Show InfoHash where | 105 | instance Show InfoHash where |
104 | show = render . ppInfoHash | 106 | show = render . ppInfoHash |