diff options
author | Joris | 2016-11-20 18:26:07 +0100 |
---|---|---|
committer | Joris | 2016-11-20 18:26:07 +0100 |
commit | 74aff92204f70a6f113039fe90d332b44f9493c2 (patch) | |
tree | eb9b6ecb3edf55be352737db9cb72a7f1c2ac87e /src/Fetch.hs | |
parent | ae45764821dc3c04eeb8c2171f14d36256ce4027 (diff) |
Enable multi-urls in config file
Diffstat (limited to 'src/Fetch.hs')
-rw-r--r-- | src/Fetch.hs | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/Fetch.hs b/src/Fetch.hs index ea82caa..5d14de4 100644 --- a/src/Fetch.hs +++ b/src/Fetch.hs @@ -1,12 +1,13 @@ {-# LANGUAGE OverloadedStrings #-} module Fetch - ( fetchResumes - , fetchAds + ( resumes + , ads ) where import Data.Text (Text) import qualified Data.Text.IO as T +import Data.Either (rights) import Page @@ -18,18 +19,16 @@ import Model.URL (URL) import qualified Parser.Resume as Resume import qualified Parser.Detail as Detail -fetchResumes :: URL -> IO (Either Text [Resume]) -fetchResumes url = do - resumes <- fmap Resume.parse <$> Page.get url - if null resumes +resumes :: [URL] -> IO [Resume] +resumes urls = do + results <- fmap (concat . map Resume.parse . rights) . sequence . map Page.get $ urls + if null results then T.putStrLn "Parsed 0 results!" else return () - return resumes + return results -fetchAds :: [Resume] -> IO (Either Text [Ad]) -fetchAds resumes = do - xs <- sequence $ map fetchAd resumes - return $ sequence xs +ads :: [Resume] -> IO (Either Text [Ad]) +ads = fmap sequence . sequence . map ad -fetchAd :: Resume -> IO (Either Text Ad) -fetchAd resume = fmap (\ad -> Ad resume (Detail.parse ad)) <$> Page.get (Resume.url resume) +ad :: Resume -> IO (Either Text Ad) +ad resume = fmap (\x -> Ad resume (Detail.parse x)) <$> Page.get (Resume.url resume) |