From 1819d80705986d36c3264f60d05a5383c73bc33f Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Wed, 12 Dec 2018 01:12:25 -0500 Subject: Reduced dependencies, updated cabal file. --- src/Data/Torrent.hs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/Data') diff --git a/src/Data/Torrent.hs b/src/Data/Torrent.hs index a746b54c..69461488 100644 --- a/src/Data/Torrent.hs +++ b/src/Data/Torrent.hs @@ -42,15 +42,19 @@ module Data.Torrent , FileOffset , FileSize , FileInfo (..) +#ifdef VERSION_lens , fileLength , filePath , fileMD5Sum +#endif -- ** Layout info , LayoutInfo (..) +#ifdef VERSION_lens , singleFile , multiFile , rootDirName +#endif , joinFilePath , isSingleFile , isMultiFile @@ -86,8 +90,10 @@ module Data.Torrent -- ** Piece control , HashList (..) , PieceInfo (..) +#ifdef VERSION_lens , pieceLength , pieceHashes +#endif , pieceCount -- ** Validation @@ -96,10 +102,12 @@ module Data.Torrent -- * Info dictionary , InfoDict (..) +#ifdef VERSION_lens , infohash , layoutInfo , pieceInfo , isPrivate +#endif #ifdef VERSION_bencoding , infoDictionary #endif @@ -107,6 +115,7 @@ module Data.Torrent -- * Torrent file , Torrent(..) +#ifdef VERSION_lens -- ** Lenses , announce , announceList @@ -118,6 +127,7 @@ module Data.Torrent , publisher , publisherURL , signature +#endif -- ** Utils , nullTorrent @@ -151,7 +161,7 @@ import Prelude hiding ((<>)) import Control.Applicative import Control.DeepSeq import Control.Exception -import Control.Lens +-- import Control.Lens import Control.Monad import Crypto.Hash #ifdef VERSION_bencoding @@ -368,12 +378,14 @@ data FileInfo a = FileInfo { , Functor, Foldable ) +#ifdef VERSION_lens makeLensesFor [ ("fiLength", "fileLength") , ("fiMD5Sum", "fileMD5Sum") , ("fiName" , "filePath" ) ] ''FileInfo +#endif instance NFData a => NFData (FileInfo a) where rnf FileInfo {..} = rnf fiName @@ -455,12 +467,14 @@ data LayoutInfo , liDirName :: !BS.ByteString } deriving (Show, Read, Eq, Typeable) +#ifdef VERSION_lens makeLensesFor [ ("liFile" , "singleFile" ) , ("liFiles" , "multiFile" ) , ("liDirName", "rootDirName") ] ''LayoutInfo +#endif instance NFData LayoutInfo where rnf SingleFile {..} = () @@ -681,11 +695,13 @@ data PieceInfo = PieceInfo -- ^ Concatenation of all 20-byte SHA1 hash values. } deriving (Show, Read, Eq, Typeable) +#ifdef VERSION_lens -- | Number of bytes in each piece. makeLensesFor [("piPieceLength", "pieceLength")] ''PieceInfo -- | Concatenation of all 20-byte SHA1 hash values. makeLensesFor [("piPieceHashes", "pieceHashes")] ''PieceInfo +#endif instance NFData PieceInfo where rnf (PieceInfo a (HashList b)) = rnf a `seq` rnf b @@ -766,6 +782,7 @@ data InfoDict = InfoDict -- BEP 27: } deriving (Show, Read, Eq, Typeable) +#ifdef VERISON_lens makeLensesFor [ ("idInfoHash" , "infohash" ) , ("idLayoutInfo", "layoutInfo") @@ -773,6 +790,7 @@ makeLensesFor , ("idPrivate" , "isPrivate" ) ] ''InfoDict +#endif instance NFData InfoDict where rnf InfoDict {..} = rnf idLayoutInfo @@ -884,6 +902,7 @@ data Torrent = Torrent -- encrypted SHA-1 hash of the info dictionary). } deriving (Show, Eq, Typeable) +#ifdef VERSION_lens makeLensesFor [ ("tAnnounce" , "announce" ) , ("tAnnounceList", "announceList") @@ -897,6 +916,7 @@ makeLensesFor , ("tSignature" , "signature" ) ] ''Torrent +#endif instance NFData Torrent where rnf Torrent {..} = rnf tInfoDict -- cgit v1.2.3