
Ryan Ingram wrote:
Normally I agree with you, apfelmus, but here at least I have to differ!
/me considers map crushToPurée . filter disagrees ;)
On Mon, Oct 13, 2008 at 11:50 AM, apfelmus
wrote: *HTML> toString $ tag "b" [] [tag "i" [] [text "<>"], text "test"] "<b><i><></i>test</b>"
I'd say the big problem is that your embedded language for describing HTML is way more complex for a domain expert than
doc = renderHTML $(q "<b><i>#{v1}</i>#{v2}</b>") where v1 = "<>" v2 = "test"
which, while somewhat error-prone in the HTML string itself, is much more likely to get used than an embedded language. One thing that "ideal in theory" solutions seem to miss out on a lot is usability;
Ok, syntactic considerations. Why again would I want to bother memorizing HTML syntax? I know the Haskell syntax, in particular the space for function application and lowercase identifiers for variables. I care little about the myriad of other notations for function application and variables that people have invented, for that's - in a sense - what all languages boil down to. How is remembering more arcane syntax more usable? Also, by embedding instead of "enshrining" a DSL like HTML in the host language, I get all the flexibility of the host language. node :: String -> [Attr] -> [Html] -> Html -- renamed from last time text :: String -> Html tag x = node x [] bold = tag "b" italic = tag "i" olist = tag "ol" . map (tag "li") table = tag "table" . map (tag "tr" . map (tag "td")) example = bold [italic $ text "<>", text "test"] dialogue = tag "dl" . map (\(speaker,talk) -> [tag "dt" [italic $ text (speaker ++ ":")] ,tag "dd" talk]) In a sense, I can define my own tags. Regards, apfelmus