diff options
author | Joris Guyonvarch | 2015-04-13 19:32:59 +0200 |
---|---|---|
committer | Joris Guyonvarch | 2015-04-13 19:32:59 +0200 |
commit | a2c9ca0ee7022981fa563ed867e85cdeae3b1590 (patch) | |
tree | ec600d8a2cf14c8059f966611b59d0d1df8bae19 /src/Fetch.hs | |
parent | c0cfd3cb3d7a963cebb40f88868e5628f361376f (diff) |
Renaming Ad.hs to Fetch.hs
Diffstat (limited to 'src/Fetch.hs')
-rw-r--r-- | src/Fetch.hs | 30 |
1 files changed, 30 insertions, 0 deletions
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) |