<?xml version="1.0" encoding="UTF-8"?>
<code>
  <code>
---
--- Tag
---

data Tag = Tag {
 tagType  :: String,
 tagAttrs :: [Attr]
}

data Attr = Attr String String

---
--- tagToHTML
---

tagToHTML :: Tag -&gt; String
tagToHTML t = "&lt;" ++ tagType t ++ " " ++ attrs ++ "/&gt;a"
          where attrs = join (map attrPair (tagAttrs t))

---
--- attrPair
---

attrPair :: Attr -&gt; String
attrPair (Attr k v) = k ++ "=\"" ++ v ++ "\""

---
--- join
---

join :: [String] -&gt; String 
join (x:xs) = x ++ " " ++ (join xs)
join [] = ""

--- main

input = Tag "input" [Attr "id" "comments", Attr "disabled" "disabled"]
main = print (tagToHTML input)</code>
  <comment>Just playing around, super new to Haskell (1 hour or so), and pointers would be great</comment>
  <created-at type="datetime">2009-04-13T01:03:01+00:00</created-at>
  <id type="integer">821</id>
  <language>Haskell</language>
  <permalink>tag</permalink>
  <refactors-count type="integer">3</refactors-count>
  <title>Tag</title>
  <trackback-url></trackback-url>
  <updated-at type="datetime">2009-04-13T15:13:36+00:00</updated-at>
  <user-id type="integer">634</user-id>
  <refactors type="array">
    <refactor>
      <code>data Tag = Tag {
 tagType  :: String,
 tagAttrs :: [Attr]
}

data Attr = Attr String String

instance Show Tag where
 show tag = foldr (++) "" ["&lt;",tagType tag," ",unwords.(map show) $ tagAttrs tag,"/&gt;"]

instance Show Attr where
 show (Attr k v) = concat [k,"=\"",v,"\""]

input = Tag "input" [Attr "id" "comments", Attr "disabled" "disabled"]
main = print input
</code>
      <code-id type="integer">821</code-id>
      <comment>Using show instances for printing operations make outputing data more transparent.
</comment>
      <created-at type="datetime">2009-04-13T09:51:41+00:00</created-at>
      <id type="integer">154921</id>
      <language>Haskell</language>
      <rating type="integer">5</rating>
      <ratings-count type="integer">2</ratings-count>
      <title>On Tag</title>
      <user-id type="integer" nil="true"></user-id>
      <user-name>sargon</user-name>
      <user-website>www.mindeye.net</user-website>
    </refactor>
    <refactor>
      <code></code>
      <code-id type="integer">821</code-id>
      <comment>arg, 
in the instance of Show Tag using concat instead of foldr will do the job with less chars ;)</comment>
      <created-at type="datetime">2009-04-13T09:54:11+00:00</created-at>
      <id type="integer">154922</id>
      <language>Haskell</language>
      <rating type="integer">0</rating>
      <ratings-count type="integer">0</ratings-count>
      <title>On Tag</title>
      <user-id type="integer" nil="true"></user-id>
      <user-name>sargon</user-name>
      <user-website></user-website>
    </refactor>
    <refactor>
      <code></code>
      <code-id type="integer">821</code-id>
      <comment>Ah I was wondering what this Show stuff was about, had a feeling there was  a much better way to do that. thanks!</comment>
      <created-at type="datetime">2009-04-13T15:13:31+00:00</created-at>
      <id type="integer">154941</id>
      <language>Haskell</language>
      <rating type="integer">0</rating>
      <ratings-count type="integer">0</ratings-count>
      <title>On Tag</title>
      <user-id type="integer">634</user-id>
      <user-name>Tj Holowaychuk</user-name>
      <user-website>http://vision-media.ca</user-website>
    </refactor>
  </refactors>
</code>
