blob: 445ef3a67db285cb42b059f5cf14c1d5b1197290 (
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
|
module View.Ad
( renderAd
) where
import Data.List (intersperse)
import Data.Maybe (fromMaybe)
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
renderAd :: Ad -> String
renderAd ad =
(renderResume (Ad.resume ad)) ++ "\n\n" ++ (renderDetail (Ad.detail ad)) ++ "\n"
renderResume :: Resume -> String
renderResume resume =
let formatPrice price = " - " ++ price
price = fromMaybe "" . fmap formatPrice . Resume.price $ resume
titleLine = (Resume.name resume) ++ price
in concat . intersperse "\n" $ [titleLine, Resume.url resume]
renderDetail :: Detail -> String
renderDetail detail =
fromMaybe "−" (Detail.description detail)
|