blob: c80a980ee4e2ca6eb6f2b680ebc613c074afa81a (
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
|
module Fetch
( fetchResumes
, fetchAds
) where
import Data.Text (Text)
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 = fmap Resume.parse <$> Page.get 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 = fmap (\ad -> Ad resume (Detail.parse ad)) <$> Page.get (Resume.url resume)
|