I think it would be useful if we spoke in more concrete terms: in particular, let's figure out some real world problems we want to solve, instead of designing the perfect technology. I'll start with some simple problems, feel free to add some of your own:
1) Form validation. Here's an example from a project I'm working on now: disable field B if field A has one of a list of values. We clearly need to ensure server-side that field B has no value set if the conditions for A are fulfilled, but we'd like to "gray out" the field client side.
because I have a copy of the HTML tree in the server( the way to maintain synchronization trough event forwarding to the server is not described here) I can check te value of the field A. If A meets the condition I just send to the browser the HTML DOM sentence
"form.B.style.active=Disabled"
(This is javascript pseudocode the real sentence look similar, but I don´t care now to check the documentation and look for the details)
in the browser the execution of
eval("form.B.style.active=Disabled" )
will disable the field.
If we develop a XML DOM library that generate javascript strings, then the haskell code in the server would map 1:1 with the javascript code.For the javascript developer will be muchi like developing javascript in the client. In fact the code would share ,much ideas and code with HJScript because HJScript does also generate javascript strings. I think that we can extend HJSCript to make it run either in the server or the client, depending on the choices. HJScript uses HTML DOM.
This case does a lot less sense if the control code does not make use of data in the server. For example, if the list of values of a combo box depends on the choice or values in another field in the form.