blob: 6f094eeb5b76513c8006f8795e612bd3e434465c (
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
36
37
38
39
|
{-# LANGUAGE OverloadedStrings #-}
module View.Ad
( renderAds
) where
import Data.List (intersperse)
import Data.Maybe (fromMaybe)
import Data.Text (Text)
import qualified Data.Text as T
import Model.Ad (Ad(..))
import qualified Model.Ad as Ad
import Model.Resume (Resume(..))
import qualified Model.Resume as Resume
import Model.Detail (Detail(..))
import qualified Model.Detail as Detail
renderAds :: [Ad] -> Text
renderAds = T.intercalate "\n\n" . map renderAd
renderAd :: Ad -> Text
renderAd ad =
T.concat
[ renderResume (Ad.resume ad)
, "\n\n"
, renderDetail (Ad.detail ad)
]
renderResume :: Resume -> Text
renderResume resume =
let formatPrice price = T.concat [" - ", price]
price = fromMaybe "" . fmap formatPrice . Resume.price $ resume
titleLine = T.concat [Resume.name resume, price]
in T.intercalate "\n" [titleLine, Resume.url resume]
renderDetail :: Detail -> Text
renderDetail detail =
fromMaybe "−" (Detail.description detail)
|