From a2c9ca0ee7022981fa563ed867e85cdeae3b1590 Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Mon, 13 Apr 2015 19:32:59 +0200 Subject: Renaming Ad.hs to Fetch.hs --- src/Ad.hs | 30 ------------------------------ src/AdListener.hs | 2 +- src/Fetch.hs | 30 ++++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 31 deletions(-) delete mode 100644 src/Ad.hs create mode 100644 src/Fetch.hs diff --git a/src/Ad.hs b/src/Ad.hs deleted file mode 100644 index 4be47f4..0000000 --- a/src/Ad.hs +++ /dev/null @@ -1,30 +0,0 @@ -module Ad - ( fetchResumes - , fetchAds - ) where - -import Data.Text (Text) -import qualified Data.Text as T - -import Page (getPage) - -import Model.Ad -import Model.Resume -import Model.Detail -import Model.URL - -import Parser.Resume -import Parser.Detail - -fetchResumes :: URL -> IO (Either Text [Resume]) -fetchResumes url = fmap parseResumes <$> getPage url - -fetchAds :: [Resume] -> IO (Either Text [Ad]) -fetchAds resumes = do - xs <- sequence $ map fetchAd resumes - return $ sequence xs - -fetchAd :: Resume -> IO (Either Text Ad) -fetchAd resume = do - page <- getPage (url resume) - fmap (\page -> Ad { resume = resume, detail = parseDetail page}) <$> getPage (url resume) diff --git a/src/AdListener.hs b/src/AdListener.hs index 0155074..21775cc 100644 --- a/src/AdListener.hs +++ b/src/AdListener.hs @@ -11,7 +11,7 @@ import qualified Data.Text.IO as T import Control.Concurrent (threadDelay) -import Ad (fetchResumes, fetchAds) +import Fetch (fetchResumes, fetchAds) import Model.Ad import Model.URL diff --git a/src/Fetch.hs b/src/Fetch.hs new file mode 100644 index 0000000..a4e8c94 --- /dev/null +++ b/src/Fetch.hs @@ -0,0 +1,30 @@ +module Fetch + ( fetchResumes + , fetchAds + ) where + +import Data.Text (Text) +import qualified Data.Text as T + +import Page (getPage) + +import Model.Ad +import Model.Resume +import Model.Detail +import Model.URL + +import Parser.Resume +import Parser.Detail + +fetchResumes :: URL -> IO (Either Text [Resume]) +fetchResumes url = fmap parseResumes <$> getPage url + +fetchAds :: [Resume] -> IO (Either Text [Ad]) +fetchAds resumes = do + xs <- sequence $ map fetchAd resumes + return $ sequence xs + +fetchAd :: Resume -> IO (Either Text Ad) +fetchAd resume = do + page <- getPage (url resume) + fmap (\page -> Ad { resume = resume, detail = parseDetail page}) <$> getPage (url resume) -- cgit v1.2.3