diff options
Diffstat (limited to 'src/View')
-rw-r--r-- | src/View/Ad.hs | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/View/Ad.hs b/src/View/Ad.hs index 020fa91..5e408f3 100644 --- a/src/View/Ad.hs +++ b/src/View/Ad.hs @@ -1,10 +1,12 @@ +{-# LANGUAGE OverloadedStrings #-} + module View.Ad - ( renderAd - , renderResume + ( renderAds ) where import Data.List (intersperse) import Data.Maybe (fromMaybe) +import qualified Data.Text as T import Model.Ad (Ad(..)) import qualified Model.Ad as Ad @@ -13,17 +15,24 @@ import qualified Model.Resume as Resume import Model.Detail (Detail(..)) import qualified Model.Detail as Detail -renderAd :: Ad -> String +renderAds :: [Ad] -> T.Text +renderAds = T.intercalate "\n\n" . map renderAd + +renderAd :: Ad -> T.Text renderAd ad = - (renderResume (Ad.resume ad)) ++ "\n\n" ++ (renderDetail (Ad.detail ad)) ++ "\n" + T.concat + [ renderResume (Ad.resume ad) + , "\n\n" + , renderDetail (Ad.detail ad) + ] -renderResume :: Resume -> String +renderResume :: Resume -> T.Text renderResume resume = - let formatPrice price = " - " ++ price + let formatPrice price = T.concat [" - ", price] price = fromMaybe "" . fmap formatPrice . Resume.price $ resume - titleLine = (Resume.name resume) ++ price - in concat . intersperse "\n" $ [titleLine, Resume.url resume] + titleLine = T.concat [Resume.name resume, price] + in T.intercalate "\n" [titleLine, T.pack . Resume.url $ resume] -renderDetail :: Detail -> String +renderDetail :: Detail -> T.Text renderDetail detail = fromMaybe "−" (Detail.description detail) |