Re: [Haskell-cafe] Generating valid html

On Wed, Nov 19, 2014 at 03:45:37PM +0100, Wojtek Narczyński wrote:
On 19.11.2014 13:17, Tobias Dammers wrote:
That's pretty much what my tamper library (http://hackage.haskell.org/package/tamper) is supposed to be. It's pretty rough around the edges still, and nowhere near as complete as Blaze itself, but it works well enough for basic HTML templating, and unlike Blaze, it is implemented as a monad transformer, which means you can integrate it with whatever monad stack you like. I couldn't find an existing solution to this myself, which is why I rolled my own. Tobias,
I'm puzzled how your library can ensure that, for example <head> has only one <title>, how / where are such rules enforced? Do you have a sample or testcase?
Ah, sorry for getting your hopes up. No, it doesn't ensure valid parent/child combinations or anything, it just does what basic Blaze-HTML does, but generalized to a monad transformer.
On the practical side, wouldn't you prefer to write, for example?
{-#LANGUAGE Rank2Types #-}
type ElementType = (Monad m, Ord t, IsString t) => TamperT t m () ->
TamperT
t m ()
a, abbr, address, area, article, aside, audio :: ElementType a = tag "a" abbr = tag "abbr" address = tag "address" area = tagS "area" article = tag "article" aside = tag "aside" audio = tag "audio"
Good point; patches welcome in case I forget doing it myself ;)
participants (1)
-
Tobias Dammers