import XHTML
-data Article = Article { title :: String,
- byline :: String,
- body_html :: String }
+newtype Title = Title { getTitle :: String }
+newtype Byline = Byline { getByline :: Maybe String }
+newtype BodyHtml = BodyHtml { getBodyHtml :: String }
+
+instance Show Title where
+ show = getTitle
+
+instance Show Byline where
+ show (Byline (Just bl)) = bl
+ show (Byline Nothing ) = ""
+
+instance Show BodyHtml where
+ show = getBodyHtml
+
+instance XHTML Title where
+ to_xhtml (Title t) = "<h2>" ++ t ++ "</h2>"
+
+instance XHTML Byline where
+ to_xhtml (Byline (Just bl)) = "<p><em>" ++ bl ++ "</em></p>"
+ to_xhtml (Byline Nothing) = ""
+
+instance XHTML BodyHtml where
+ to_xhtml = getBodyHtml
+
+data Article = Article { title :: Title,
+ byline :: Byline,
+ body_html :: BodyHtml }
instance XHTML Article where
to_xhtml (Article t bl b) =
- "<h2>" ++ t ++ "</h2>\n\n" ++
- "<p><em>" ++ bl ++ "</em></p>\n\n" ++
- b
+ (to_xhtml t) ++
+ (to_xhtml bl) ++
+ (to_xhtml b)