aboutsummaryrefslogtreecommitdiff
path: root/src/View
diff options
context:
space:
mode:
authorJoris Guyonvarch2015-04-11 19:20:04 +0200
committerJoris Guyonvarch2015-04-11 19:20:04 +0200
commit4ddd6d1f6df2bab75d42b6d45b816e92e7173529 (patch)
tree09ddfd62fe32e210a87eb15eb86ee07ab9f24623 /src/View
parent88b7f848da3515d67cfb989b98ad5285a037993e (diff)
Fixing parsing errors, and use Text from now
Diffstat (limited to 'src/View')
-rw-r--r--src/View/Ad.hs27
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)