Hi Jeremy,
I've actually had quite a lot of thoughts about refactoring the structure of the whole HSP/HSX family. What you say is a step in that direction, but there's more to it. Let me try to paint the whole picture as I see it:
The support for the XML-in-Haskell extension is built up by four different layers:
1: trhsx (depending *only* on haskell-src-exts) provides *syntactic* support for XML inlined in Haskell code. This is really just syntactic sugar.
2: HSX.XMLGenerator provides a semantic framework to use with the syntax, but could (in theory) be used without trhsx and the XML syntax.
3: HSP.XMLGenerator and the HSPT monad provides a contextual framework that is an instance of the semantic framework of HSX.
4: HSP.XML (and the other modules you note) provides an implementation of the base type to be used with HSX, and HSP's implementation of HSX.
To make a crude analogy, 1 would correspond to the do-notation, 2 would be the Monad class and 3 would be a particular monad (and 4 doesn't fit the analogy, it would be like the values of a monad that always produced the same kind of values).
Right now the hsx package implements 1 and 2, and the hsp package implements 3 and 4. What you suggest is to separate 3 from 4, which I definitely sympathize with. However, I would hesitate to then lump 4 together with 1 and 2 - that sounds to me like solving one problem by creating another.
I am more thinking along the lines of, what possibilities could we get by separating all four? Especially 1 and 2 seem interesting to separate, in the same line of thinking as rebindable syntax for e.g. the do-notation. For example, I recall that Neil Mitchell used an early version of trhsx solely as a syntactic preprocessor, and used his own home-rolled library that provided the (then-equivalents of the) 'genElement' et al functions.
Doing this split would allow us to look at support for other systems on many different level. E.g., could we provide integrated blaze-builder support in the HSX.XMLGenerator framework, or is there a more natural model that just reuses the syntax?
One possible downside of this is (an even larger extent of) package proliferation madness. I think the right solution there is clear documentation though, not artificial lumping.
Thoughts?
Cheers,
/Niklas