diff options
Diffstat (limited to 'src/Data/Torrent/Piece.hs')
-rw-r--r-- | src/Data/Torrent/Piece.hs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Data/Torrent/Piece.hs b/src/Data/Torrent/Piece.hs index 00d4b843..d79da2ee 100644 --- a/src/Data/Torrent/Piece.hs +++ b/src/Data/Torrent/Piece.hs | |||
@@ -54,14 +54,15 @@ import Data.Bits.Extras | |||
54 | import Data.ByteString as BS | 54 | import Data.ByteString as BS |
55 | import qualified Data.ByteString.Lazy as BL | 55 | import qualified Data.ByteString.Lazy as BL |
56 | import qualified Data.ByteString.Base64 as Base64 | 56 | import qualified Data.ByteString.Base64 as Base64 |
57 | import Data.Char | ||
58 | import Data.Int | 57 | import Data.Int |
59 | import Data.List as L | ||
60 | import Data.Text.Encoding as T | 58 | import Data.Text.Encoding as T |
61 | import Data.Typeable | 59 | import Data.Typeable |
62 | import Text.PrettyPrint | 60 | import Text.PrettyPrint |
63 | import Text.PrettyPrint.Class | 61 | import Text.PrettyPrint.Class |
64 | 62 | ||
63 | import Data.Torrent.JSON | ||
64 | |||
65 | |||
65 | -- TODO add torrent file validation | 66 | -- TODO add torrent file validation |
66 | class Lint a where | 67 | class Lint a where |
67 | lint :: a -> Either String a | 68 | lint :: a -> Either String a |
@@ -129,7 +130,7 @@ data Piece a = Piece | |||
129 | , pieceData :: !a | 130 | , pieceData :: !a |
130 | } deriving (Show, Read, Eq, Functor, Typeable) | 131 | } deriving (Show, Read, Eq, Functor, Typeable) |
131 | 132 | ||
132 | $(deriveJSON defaultOptions { fieldLabelModifier = (L.map toLower . L.dropWhile isLower) } ''Piece) | 133 | $(deriveJSON omitRecordPrefix ''Piece) |
133 | 134 | ||
134 | instance NFData (Piece a) | 135 | instance NFData (Piece a) |
135 | 136 | ||
@@ -166,7 +167,7 @@ data PieceInfo = PieceInfo | |||
166 | -- ^ Concatenation of all 20-byte SHA1 hash values. | 167 | -- ^ Concatenation of all 20-byte SHA1 hash values. |
167 | } deriving (Show, Read, Eq, Typeable) | 168 | } deriving (Show, Read, Eq, Typeable) |
168 | 169 | ||
169 | $(deriveJSON defaultOptions { fieldLabelModifier = (L.map toLower . L.dropWhile isLower) } ''PieceInfo) | 170 | $(deriveJSON omitRecordPrefix ''PieceInfo) |
170 | 171 | ||
171 | -- | Number of bytes in each piece. | 172 | -- | Number of bytes in each piece. |
172 | makeLensesFor [("piPieceLength", "pieceLength")] ''PieceInfo | 173 | makeLensesFor [("piPieceLength", "pieceLength")] ''PieceInfo |