blob: 5d14de41dfe56ce6bd23f4bc71ec0cca7768e4db (
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
|
{-# LANGUAGE OverloadedStrings #-}
module Fetch
( resumes
, ads
) where
import Data.Text (Text)
import qualified Data.Text.IO as T
import Data.Either (rights)
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
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 results
ads :: [Resume] -> IO (Either Text [Ad])
ads = fmap sequence . sequence . map ad
ad :: Resume -> IO (Either Text Ad)
ad resume = fmap (\x -> Ad resume (Detail.parse x)) <$> Page.get (Resume.url resume)
|