Skip to content

Instantly share code, notes, and snippets.

@michaelt
Forked from LnL7/html.hs
Created July 28, 2012 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelt/3194079 to your computer and use it in GitHub Desktop.
Save michaelt/3194079 to your computer and use it in GitHub Desktop.
module HTML where
class Tag a where
toHTML :: a -> String
data Attribute = Attribute {
key :: String,
value :: String
} deriving Show
instance Tag Attribute where
toHTML (Attribute {key=key, value=val}) = key ++ "=\"" ++ val ++ "\""
instance Tag [Attribute] where
toHTML (attr : attrs) = " " ++ toHTML attr ++ toHTML attrs
toHTML [] = ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment