
I have been experimenting with a Widget system based on HSX+HJScript. The biggest issue I have run into seems to be marshaling your data between Haskell and Javascript. The problem is that the two languages offer fairly different and incompatible data representations. But you often want to send data back and forth between the client (javascript) and server (Haskell). You have 5 choices, that I can think of: 1. Use nice algebraic types. This makes your Haskell code nice, but working with algebraic types in javascript is a pain. [1] 2. Use objects (json) for your types. This makes the javascript easier to work with, but is a type mess in Haskell and not easy to work with. 3. Use algebraic types in Haskell, and Objects in javascript. This makes the data easy to work with in both language, but you have to be able to convert from one style to another. In my opinion, that requires writing both representations by hand and the marshaling functions by hand. Then anytime you change the type, you have to change both types (the haskell and javascript versions) and update the marshal functions. There is also no guarantee that you did any of it right with out testing. 4. Create a DSL for defining types which automatically generates the Haskell/javascript datatypes. This would presumably use a fairly limited set of types such that the types it generates are 'friendly' to use in both the Haskell and javascript-side. The drawback is that it is likely to be restrictive enough that it is not especially nice to use in either language. (Likely to be somewhat verbose I think...) 5. Compile haskell-to-javascript (or something along those lines), so that you only think in Haskell and don't have to think about javascript or javascript types. This is nice because you only have to think in one language, etc. But performance of the javascript code is a concern. And it makes it difficult to leverage existing javascript libraries like jQuery (because jquery is going to want javascripty types, etc). I'd like to hear about other options, or implementations of those options that work well.. - jeremy I have not tried using this algrebraic data type library for javascript yet.. because I just remembered it existed. [1] http://w3future.com/weblog/stories/2008/06/16/adtinjs.xml On Jun 22, 2010, at 8:53 AM, Sergey Mironov wrote:
Hi! This is definitely the right way. Current set of related technologies includes Formlets, HJScript, Web-routes, various template systems like Hamlet or HSX.
3 create a minimum javascript module that: read Ajax responses and execute them in the web browser, for the above functionality listen for events and forward them to the server trough Ajax.
Ajax is just one approach of several existing. Building a haskell-to-JavaScript generator looks more important for me. Please look at [1] and [2]. what do you think?
Generally, it is already possible to manage client java-scripts on the server with HSX + HJScript [3]. On the other hand, managing pure html forms for JScript-free apps is possible with the help of Formlets. But when one starts using them all together, code becomes awkward.
[1] http://www.haskell.org/haskellwiki/Haskell_in_web_browser [2] http://vir.mskhug.ru/ [3] http://git.ierton.ru/?p=happstack-samples.git;a=blob_plain;f=HJSample.hs;hb=...
-- Thanks, Sergey _______________________________________________ web-devel mailing list web-devel@haskell.org http://www.haskell.org/mailman/listinfo/web-devel