]> gitweb.michael.orlitzky.com - dead/lwn-epub.git/blob - src/LWN/Article.hs
70c68a5190d724fc2663531c57a63d02efb7c227
[dead/lwn-epub.git] / src / LWN / Article.hs
1 module LWN.Article
2 where
3
4 import XHTML
5
6 newtype Title = Title { getTitle :: String }
7 newtype Byline = Byline { getByline :: Maybe String }
8 newtype BodyHtml = BodyHtml { getBodyHtml :: String }
9
10 instance Show Title where
11 show = getTitle
12
13 instance Show Byline where
14 show (Byline (Just bl)) = bl
15 show (Byline Nothing ) = ""
16
17 instance Show BodyHtml where
18 show = getBodyHtml
19
20 instance XHTML Title where
21 to_xhtml (Title t) = "<h2>" ++ t ++ "</h2>"
22
23 instance XHTML Byline where
24 to_xhtml (Byline (Just bl)) = "<p><em>" ++ bl ++ "</em></p>"
25 to_xhtml (Byline Nothing) = ""
26
27 instance XHTML BodyHtml where
28 to_xhtml = getBodyHtml
29
30 data Article = Article { title :: Title,
31 byline :: Byline,
32 body_html :: BodyHtml }
33
34 instance XHTML Article where
35 to_xhtml (Article t bl b) =
36 (to_xhtml t) ++
37 (to_xhtml bl) ++
38 (to_xhtml b)