From 721aeee745cc308014b80594b4c6b7b403d4ef1f Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
Date: Sun, 13 Sep 2015 20:17:48 +0530
Subject: [PATCH] remove the use of ReaderT

---
 src/FuncTorrent/Tracker.hs | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/src/FuncTorrent/Tracker.hs b/src/FuncTorrent/Tracker.hs
index 5cd6aea..a2dc48b 100644
--- a/src/FuncTorrent/Tracker.hs
+++ b/src/FuncTorrent/Tracker.hs
@@ -1,15 +1,11 @@
 {-# LANGUAGE OverloadedStrings #-}
 module FuncTorrent.Tracker
     (TrackerResponse(..),
-     mkArgs,
-     getTrackerResponse,
-     urlEncodeHash
+     getTrackerResponse
     ) where
 
 import Prelude hiding (lookup, splitAt)
 
-import Control.Monad.IO.Class (liftIO)
-import Control.Monad.Reader (ReaderT, ask, runReaderT)
 import Data.ByteString (ByteString)
 import Data.ByteString.Char8 as BC (pack, unpack, splitAt)
 import Data.Char (chr)
@@ -67,18 +63,15 @@ mkTrackerResponse resp =
           where (ip', port') = splitAt 4 peer
 
 -- | Connect to a tracker and get peer info
-tracker :: String -> ReaderT Metainfo IO ByteString
-tracker peer_id = do
-  m <- ask
-  let args = mkArgs peer_id m
-  liftIO $ get (head . announceList $ m) args
-
-getTrackerResponse ::  String -> ReaderT Metainfo IO (Either ByteString TrackerResponse)
-getTrackerResponse peerId = do
-  m <- ask
-  resp <- liftIO $ runReaderT (tracker peerId) m
+tracker :: String -> Metainfo -> IO ByteString
+tracker peer_id m = do
+  get (head . announceList $ m) $ mkArgs peer_id m
+
+getTrackerResponse ::  String -> Metainfo -> IO (Either ByteString TrackerResponse)
+getTrackerResponse peerId m = do
+  resp <- tracker peerId m
   case decode resp of
-   Right trackerInfo -> liftIO $ return $ mkTrackerResponse trackerInfo
+   Right trackerInfo -> return $ mkTrackerResponse trackerInfo
    Left e -> return $ Left (pack (show e))
 
 --- | URL encode hash as per RFC1738
-- 
2.45.2