From: Jaseem Abid Date: Sun, 22 Feb 2015 17:04:44 +0000 (+0530) Subject: Make `!` inline X-Git-Url: https://git.rkrishnan.org/Site/Content/Exhibitors/%22news.html/%22file:/htmlfontify-example.html?a=commitdiff_plain;h=44915b08c7ebea50492dc7b441f0cd8e0180f072;p=functorrent.git Make `!` inline --- diff --git a/src/Bencode.hs b/src/Bencode.hs index 8018a38..246fffc 100644 --- a/src/Bencode.hs +++ b/src/Bencode.hs @@ -128,4 +128,4 @@ encode (Bint i) = "i" ++ show i ++ "e" encode (Blist xs) = "l" ++ encodeList xs ++ "e" where encodeList = foldr ((++) . encode) "" encode (Bdict d) = "d" ++ encodeDict d ++ "e" - where encodeDict m = concat [encode k ++ encode ((!) m k) | k <- keys m] + where encodeDict m = concat [encode k ++ encode (m ! k) | k <- keys m] diff --git a/src/Metainfo.hs b/src/Metainfo.hs index ccfd983..c77b127 100644 --- a/src/Metainfo.hs +++ b/src/Metainfo.hs @@ -24,11 +24,11 @@ data Metainfo = Metainfo { info :: !Info } deriving (Eq, Show) mkInfo :: BVal -> Maybe Info -mkInfo (Bdict m) = let (Bint pieceLength') = m M.! Bstr (pack "piece length") - (Bstr pieces') = m M.! Bstr (pack "pieces") +mkInfo (Bdict m) = let (Bint pieceLength') = m ! Bstr (pack "piece length") + (Bstr pieces') = m ! Bstr (pack "pieces") private' = Nothing - (Bstr name') = m M.! Bstr (pack "name") - (Bint length') = m M.! Bstr (pack "length") + (Bstr name') = m ! Bstr (pack "name") + (Bint length') = m ! Bstr (pack "length") md5sum' = Nothing in Just Info { pieceLength = pieceLength' , pieces = pieces' @@ -44,8 +44,8 @@ maybeBstrToString (Just s) = let (Bstr bs) = s in Just (unpack bs) mkMetaInfo :: BVal -> Maybe Metainfo -mkMetaInfo (Bdict m) = let (Just info') = mkInfo (m M.! Bstr (pack "info")) - (Bstr announce') = m M.! Bstr (pack "announce") +mkMetaInfo (Bdict m) = let (Just info') = mkInfo (m ! Bstr (pack "info")) + (Bstr announce') = m ! Bstr (pack "announce") -- announceList = lookup (Bstr (pack "announce list")) announceList' = Nothing -- creationDate = lookup (Bstr (pack "creation date")) m diff --git a/src/Peer.hs b/src/Peer.hs index e27de57..b07b79d 100644 --- a/src/Peer.hs +++ b/src/Peer.hs @@ -36,7 +36,7 @@ getPeerResponse :: ByteString -> PeerResp getPeerResponse body = case decode body of Right (Bdict peerM) -> let (Just (Bint i)) = lookup (Bstr (pack "lookup")) peerM - (Bstr peersBS) = peerM M.! Bstr (pack "peers") + (Bstr peersBS) = peerM ! Bstr (pack "peers") pl = map (\peer -> let (ip', port') = splitAt 4 peer in Peer (toIPNum ip') (toPortNum port')) (splitN 6 peersBS) diff --git a/src/Tracker.hs b/src/Tracker.hs index eab0979..09d5529 100644 --- a/src/Tracker.hs +++ b/src/Tracker.hs @@ -30,7 +30,7 @@ urlEncodeHash bs = concatMap (encode' . unpack) (splitN 2 bs) nonSpecialChars = ['A'..'Z'] ++ ['a'..'z'] ++ ['0'..'9'] ++ "-_.~" infoHash :: Map BVal BVal -> ByteString -infoHash m = let info = m M.! Bstr (pack "info") +infoHash m = let info = m ! Bstr (pack "info") in (hash . pack . encode) info prepareRequest :: InfoDict -> String -> Integer -> String