[Haskell-cafe] Haskell/JS -- better through typeclasses?

Dimitry Golubovsky golubovsky at gmail.com
Sun Apr 26 09:44:45 EDT 2009


Jason and everybody interested,

Please check out a package I recently (just by coincidence: I haven't
seen this topic on the list until after I uploaded it) uploaded to
Hackage:

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/jsmw-0.1

This is a basic monadic interface to Javascript code generator (based
on WebBits), providing sort of a macro (like in macro-assembler)
facility. HJScript was used as a (sort of) prototype, but I chose
slightly different notation for EDSL.

>From here, I think two directions may be taken:

1. Some techniques are described in the GRIN thesis [1] how to convert
a Haskell core to monadic form. These may be explored for this case.

2. Similarly to how the Web Consortium defined interfaces to its
components using IDL *, Haskell modules converted to Javascript may
expose their interfaces same way, thus providing a basis for a
reusable component-based approach.

Any discussions and suggestions are welcome.

>From my own impressions, EDSL approach is better for interactive/AJAX
parts of a Javascript application, as translation of non-strict
evaluation (like it was done in the Yhc/Javascript project) just
causes a lot of code generated, and does not improve the user
interaction performance at all. For other (internal) components,
translation from Haskell may be more appropriate, just to be able to
reuse the existing libraries.

One of experiments with Yhc involved a user-exposed form, and a parser
to validate user's input. With this hybrid approach, the user
interface part might be coded using an EDSL, and the parser could be
translated from Haskell core. An IDL might be generated for the parser
interface, thus making the parser module a reusable component. These
are of course just thoughts and ideas for now.

------------------------------------
* See the DOM package: this is an auto-generated Haskel approximation
of IDL specs provided for the basic DOM components.

[1] http://www.cs.chalmers.se/~boquist/phd/index.html
[2] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/DOM-2.0.1

-- 
Dimitry Golubovsky

Anywhere on the Web


More information about the Haskell-Cafe mailing list