blob: ea82caabca8f6713a86b141af2a48e8cbee1a61b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
{-# LANGUAGE OverloadedStrings #-}
module Fetch
( fetchResumes
, fetchAds
) where
import Data.Text (Text)
import qualified Data.Text.IO as T
import Page
import Model.Ad (Ad(Ad))
import Model.Resume (Resume)
import qualified Model.Resume as Resume
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
then T.putStrLn "Parsed 0 results!"
else return ()
return resumes
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 = fmap (\ad -> Ad resume (Detail.parse ad)) <$> Page.get (Resume.url resume)
|