summaryrefslogtreecommitdiff
path: root/src/Data/Torrent/Piece.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Data/Torrent/Piece.hs')
-rw-r--r--src/Data/Torrent/Piece.hs9
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
54import Data.ByteString as BS 54import Data.ByteString as BS
55import qualified Data.ByteString.Lazy as BL 55import qualified Data.ByteString.Lazy as BL
56import qualified Data.ByteString.Base64 as Base64 56import qualified Data.ByteString.Base64 as Base64
57import Data.Char
58import Data.Int 57import Data.Int
59import Data.List as L
60import Data.Text.Encoding as T 58import Data.Text.Encoding as T
61import Data.Typeable 59import Data.Typeable
62import Text.PrettyPrint 60import Text.PrettyPrint
63import Text.PrettyPrint.Class 61import Text.PrettyPrint.Class
64 62
63import Data.Torrent.JSON
64
65
65-- TODO add torrent file validation 66-- TODO add torrent file validation
66class Lint a where 67class 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
134instance NFData (Piece a) 135instance 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.
172makeLensesFor [("piPieceLength", "pieceLength")] ''PieceInfo 173makeLensesFor [("piPieceLength", "pieceLength")] ''PieceInfo