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

Bardur Arantsson spam at scientician.net
Wed Mar 7 06:14:54 CET 2012


On 03/06/2012 11:38 PM, Christopher Done wrote:
> I might as well chime in on this thread as it is relevant to my
> interests. I made a write up on a comparison of HJScript (JavaScript
> EDSL) and my Ji (control browser from Haskell) library:
> https://github.com/chrisdone/ji
>
> 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
>

HJScript (0.5.0) generates invalid Javascript if you try to use 
anonymous functions.

(Digs through email archives... Ah, yes:)

-------------------- snip --------------------
Given

 > testJS :: HJScript ()
 > testJS = do
 >   f <- function (\(e :: JInt) -> do
 >                     x <- inVar true
 >                     return $ x)
 >   callProc f (int 3)
 >   return ()
 >
 > main :: IO ()
 > main = do
 >   putStrLn $ "JS: " ++ (show $ evalHJScript $ testJS)

We get the output

 > function (param0_0){var var_1 = true;return var_1;}(3);

But this is invalid syntax in JavaScript, and should really be

 > (function (param0_0){var var_1 = true;return var_1;})(3);

... which works.

-------------------- snip --------------------

Just something to be aware of.

(For my particular usage it was also too strictly typed, but that's 
another matter.)

Regards,




More information about the Haskell-Cafe mailing list