[Haskell-cafe] [ANNAUNCE] ghcjs-0.1.0 Haskell to Javascript
compiler
Martijn Schrage
martijn at oblomov.com
Wed Oct 27 11:46:53 EDT 2010
On 27-10-10 16:20, Victor Nazarov wrote:
> Very cool. I'll incorporate your changes, If you don't mind.
Not at all.
> However, I have some minor remarks.
> You shouldn't override hscall function, or you may break partial
> application implementation. And you shouldn't overide properties of
> evalFn, I wonder that this doesn't break your example...
Ah, yes, that was the guessing part. I just hacked around a bit and
thought I'd leave the correct definition to someone who actually knows
what they're doing :-)
> var evalFn = new $hs.Func(1);
> evalFn.evaluate(arg) = function(arg) {
> var argStr = $hs.fromHaskellString(arg);
> var res = eval(argStr);
> return $hs.toHaskellString(arg); // This function should be added to
> $hs object/namespace
> }
This works without any problems (after changing the second line to:
"evalFn.evaluate = function(arg) {")
> I think we should do something like this:
>
> data JsObject = ... -- Should be made abstract
>
> and
>
> eval :: String -> [JsObject] -> JS JsObject
>
> So we can pass around javascript-objects in haskell program and bind
> them back into javascript calls.
> And use some conversion functions in case when we need data:
>
> jsObjectToString :: JsObject -> JS String
> jsObjectToInt :: JsObject -> JS Int
Yes, that seems logical. The JsObjects can then be treated similar to
IORefs.
What are your plans with the package? In my opinion, this work could be
extremely useful for building Ajax apps, and it doesn't seem to be that
far from being usable already.
Some interesting near-future work I can think of:
- Make it work on all major browsers
- A faster and more robust module loader (now it loses a lot of time on
404 errors, trying to access modules in the wrong package dir)
- Basic type checking for the top-level Haskell functions
- Marshaling between Haskell and JavaScript values
- JQuery support
- Nice ways to build JavaScript (and JQuery) expressions in Haskell
- Support more libraries and packages (Parsec would be interesting)
I can find some spare time to work on this. I'm sure there will be
others as well.
Cheers,
Martijn
More information about the Haskell-Cafe
mailing list