HTML.hs 964 B

12345678910111213141516171819202122232425262728293031323334
  1. module HTML where
  2. -- | Concats two strings, but puts a newline between them
  3. (+.) :: String -> String -> String
  4. x +. y = x ++ "\n" ++ y
  5. h1, h2, h3, p, tr, td, li :: String -> String
  6. h1 = simplehtml "h1"
  7. h2 = simplehtml "h2"
  8. h3 = simplehtml "h3"
  9. p = simplehtml "p"
  10. tr = simplehtml "tr"
  11. td = simplehtml "td"
  12. li = simplehtml "li"
  13. tr', td', div, span, p' :: String -> String -> String
  14. tr' = styledhtml "tr"
  15. td' = styledhtml "td"
  16. div = styledhtml "div"
  17. span = styledhtml "span"
  18. p' = styledhtml "p"
  19. a :: String -> String -> String
  20. a link name = "<a href=\"" ++ link ++ "\">" ++ name ++ "</a>"
  21. img :: String -> String -> String
  22. img url alt = "<img src=\"" ++ url ++ "\" alt=\"" ++ alt ++ "\">"
  23. simplehtml :: String -> (String -> String)
  24. simplehtml tag = \s -> "<" ++ tag ++ ">" ++ s ++ "</" ++ tag ++ ">"
  25. styledhtml :: String -> String -> (String -> String)
  26. styledhtml tag style = \s -> "<" ++ tag ++ " class=\"" ++ style ++ "\">"++ s ++ "</" ++ tag ++ ">"