From: Ramakrishnan Muthukrishnan Date: Sun, 19 Jul 2015 08:47:50 +0000 (+0530) Subject: keep hlint happy X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri/frontends/%22news.html/CLI.txt?a=commitdiff_plain;h=639dfd61fe8cbecac6f447c45dbb7f4f7263c904;p=functorrent.git keep hlint happy --- diff --git a/src/FuncTorrent/Metainfo.hs b/src/FuncTorrent/Metainfo.hs index daf008f..9eb9955 100644 --- a/src/FuncTorrent/Metainfo.hs +++ b/src/FuncTorrent/Metainfo.hs @@ -83,7 +83,7 @@ getAnnounceList (Just (Bdict _)) = [] torrentToMetainfo :: ByteString -> Either String Metainfo torrentToMetainfo s = - case (decode s) of + case decode s of Right d -> mkMetaInfo d Left e -> diff --git a/src/FuncTorrent/Peer.hs b/src/FuncTorrent/Peer.hs index 490f080..5476121 100644 --- a/src/FuncTorrent/Peer.hs +++ b/src/FuncTorrent/Peer.hs @@ -28,10 +28,10 @@ type IP = String type Port = Integer data PeerState = PeerState { handle :: Handle - , am_choking :: Bool - , am_interested :: Bool - , peer_choking :: Bool - , peer_interested :: Bool} + , amChoking :: Bool + , amInterested :: Bool + , peerChoking :: Bool + , peerInterested :: Bool} -- Maintain info on every piece and the current state of it. -- should probably be a TVar. @@ -173,14 +173,14 @@ bitfieldToList :: [Word8] -> [Integer] bitfieldToList bs = go bs 0 where go [] _ = [] go (b:bs') pos = - let setBits = [pos*8 + (toInteger i) | i <- [0..8], testBit b i] + let setBits = [pos*8 + toInteger i | i <- [0..8], testBit b i] in - setBits ++ (go bs' (pos + 1)) + setBits ++ go bs' (pos + 1) -- downloadPiece :: Integer -> Handle -> IO () createDummyFile :: FilePath -> Int -> IO () -createDummyFile path size = do +createDummyFile path size = writeFile path (BC.replicate size '\0') -- loop1 :: shake hands with all peers, find out the pieces they have, form PieceData. @@ -196,13 +196,13 @@ msgLoop h pieceHash = case msg of BitFieldMsg bss -> do let pieceList = bitfieldToList (unpack bss) - putStrLn (show pieceList) + print pieceList -- download each of the piece in order - _ -> putStrLn (show msg) + _ -> print msg handlePeerMsgs :: Peer -> Metainfo -> String -> (String -> IO ()) -> IO () handlePeerMsgs p m peerId logFn = do h <- handShake p (infoHash m) peerId - logFn $ "handShake" + logFn "handShake" msgLoop h (pieces (info m)) diff --git a/src/Main.hs b/src/Main.hs index 8171d38..12af02e 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -41,7 +41,7 @@ main = do log "Starting up functorrent" log $ "Parsing arguments " ++ concat args torrentStr <- parse args - case (torrentToMetainfo torrentStr) of + case torrentToMetainfo torrentStr of Left e -> logError e log Right m -> do log "Input File OK"