[Haskell-cafe] do like notation works fine when using ghc head
marco-oweber at gmx.de
Fri Sep 12 18:51:34 EDT 2008
> There is also the combinator approach of Text.Html, which
> gives you a syntax similar to (3) but without abusing "do":
> (rootElt ! [xmlns "http://www.w3.org/1999/xhtml",
> lang "en-US" >> xml:lang "en-US"]) $ concatXml
> [head $ title $ text "minimal"
> ,body $ concatXml
> [h1 $ text "minimal"
> ,div $ text $ "args passed to this program: " ++ (show args)
Keep in mind that my library tries to do real DTD type checking.
This means that
body, h1, div
all have different types. So they can't easily be put into a list.
And yes: I care about each character I have to type less :-)
About IO (). IO was just a poor man example to show that you can nest
arbitrary monads. Have a look at the WASH library to see in which
wonderful ways this can be used..
One working snippet from the testXHTML.hs sample file provided by the
tDo $ runHtmlDoc $ vdo
head $ title $ text "text"
body $ vdo
h2 $ text "That's a headline, hello and how do you do?"
-- br e eg a <br/> is not allowed here
div $ vdo
text "text within the div"
return "That's nice, isn't it?"
vxmldos.h defines a vdo cpp macro which expands to
let .... ; in $ do
where ... rebinds >>=, >>, lift to make this work (in with ghc head)
The library can now cope with fancy dts such as (a*)* etc as well
If you still find bugs let me know.
The more interesting part starts now: figuring out how do build a nice
HTML library on top of this all.
More information about the Haskell-Cafe