diff options
Diffstat (limited to 'src/View')
-rw-r--r-- | src/View/Ad.hs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/View/Ad.hs b/src/View/Ad.hs new file mode 100644 index 0000000..445ef3a --- /dev/null +++ b/src/View/Ad.hs @@ -0,0 +1,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) |