diff options
author | Joris Guyonvarch | 2015-04-11 19:20:04 +0200 |
---|---|---|
committer | Joris Guyonvarch | 2015-04-11 19:20:04 +0200 |
commit | 4ddd6d1f6df2bab75d42b6d45b816e92e7173529 (patch) | |
tree | 09ddfd62fe32e210a87eb15eb86ee07ab9f24623 /src/Ad.hs | |
parent | 88b7f848da3515d67cfb989b98ad5285a037993e (diff) |
Fixing parsing errors, and use Text from now
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) |