This seems to contain just what I was looking for. Although I'm not using HSP, it looks like the HSPClientside library can be used (in conjunction with Text.XHtml) to generate webpages with embedded scripts.
It sure should be possible to use HSPClientside with Text.XHtml,
but off course with exceptions to all Haskell Server Pages (HSP) specific functions. Anyway I encourage you to have a look at HSP as well :-)
It's quite nice to be able to use regular XML syntax within the Haskell code.