diff options
Diffstat (limited to 'src/Ad.hs')
-rw-r--r-- | src/Ad.hs | 24 |
1 files changed, 8 insertions, 16 deletions
@@ -1,9 +1,10 @@ module Ad - ( getAds - , getResumes + ( getResumes + , getAds ) where import Page (getPage) +import qualified Data.Text as T import Model.Ad import Model.Resume @@ -13,24 +14,15 @@ import Model.URL import Parser.Resume import Parser.Detail -getResumes :: URL -> IO (Either String [Resume]) +getResumes :: URL -> IO (Either T.Text [Resume]) getResumes url = fmap parseResumes <$> getPage url -getAds :: URL -> IO (Either String [Ad]) -getAds url = do - eitherPage <- getPage url - case eitherPage of - Left error -> - return (Left error) - Right page -> - getAdsFromPage page - -getAdsFromPage :: String -> IO (Either String [Ad]) -getAdsFromPage page = do - xs <- sequence $ map getAd (parseResumes page) +getAds :: [Resume] -> IO (Either T.Text [Ad]) +getAds resumes = do + xs <- sequence $ map getAd resumes return $ sequence xs -getAd :: Resume -> IO (Either String Ad) +getAd :: Resume -> IO (Either T.Text Ad) getAd resume = do page <- getPage (url resume) fmap (\page -> Ad { resume = resume, detail = parseDetail page}) <$> getPage (url resume) |