[Haskell-cafe] Summer of Code idea: Haskell Web Toolkit

Ryan Newton rrnewton at gmail.com
Sun Mar 18 13:15:59 CET 2012

> HJScript is "OK", hpaste.org uses it here:
> https://github.com/chrisdone/amelie/blob/master/src/Amelie/View/Script.hs
> output here: http://hpaste.org/js/amelie.js
> Mini-summary of my experience: You're still stuck with JS semantics,
> and it can be a little odd when you confuse what level of code (JS or
> HS) you're working at, but at least it works right now and can be
> well-typed. The library needs a bit of an overhaul, the GADT of
> HJavaScript is simply flawed (take a brief look and you can see it can
> express totally invalid JS in the syntax tree and the pretty printer
> breaks operator/parens), but HJScript sorts the latter out, and I
> would make all HJScript's functions generic upon MonadJS or something,

It seems like the unavoidable fact is that HJScript is a library almost
without documentation and without examples/tests.  And for an EDSL that
would seem to be an especially big problem, almost, but not quite as bad as
being told to learn Haskell by being given a GHCI prompt and left to trial
and error.

I've been trying to generate the following line of code:

    google.load("visualization", "1", {packages:["corechart"]});

I don't know JS, and my reverse engineering of this one line failed in two

    callVoidMethod "load" (string "visualization", string "1", JConst
"{packages:[\"corechart\"]}") (TopLvl "google")

First, there are classes like IsDeref and IsClass with no clear recipe for
how to create values and types satisfying them.  Hence "TopLvl", which is
my own introduced hack:

    data TopLvl = TopLvl String
    instance Show TopLvl where
      show (TopLvl s) = s
    instance IsClass TopLvl

Second, I couldn't figure out how to generate a dictionary/record
expression such as {packages:"core chart"}.  It doesn't seem to be part of
the data model of the underlying HJavaScript package:


Although it's probably possibly to build up that record in a variable
binding through some series of assignments, though I haven't found it yet...

What would help enormously, in addition to some documentation patches
[which I will try to provide if I use the library further], would be a
parser from JS concrete syntax to the HJavaScript AST.

Anyway, at this point it seems MUCH easier to just produce strings, which
is too bad.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120318/61798fef/attachment.htm>

More information about the Haskell-Cafe mailing list