Nuno Santos wrote:
Hi,

I have this basic question of how to print the character " without
the backslash.

I'm trying to print html code, so i need " a lot.

 giveHtml (Leaf (a,(b,c))) = "<frame src=\"\" name=\"" ++ [a] ++ "\"
scrolling=\"No\" noresize=\"noresize\" id=\"" ++ [a] ++ "\" title=\""
++ [a] ++ "\" />"

Can anybody give me a light here?

One way would be to define a helper function to write an opening tag given the tag name and a list of (var,value) pairs:

tag :: String -> [(String,String)] -> String
tag t ps = "<" ++ t ++ " "
   ++ concatMap (\(var, value) -> var ++ "=\"" ++ value ++ "\" ") ps
   ++ ">"

then your code would become escape free:

   giveHtml (Leaf (a,(b,c))) =
          tag "frame"
                [ ("src", "")
                , ("name", [a])
                , ("scrolling", "No")
                , ("noresize", "noresize")
                , ("id", [a])
                , ("title", [a])
                ]

Regards, Brian.

--
Logic empowers us and Love gives us purpose.
Yet still phantoms restless for eras long past,
congealed in the present in unthought forms,
strive mightily unseen to destroy us.

http://www.metamilk.com
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to