stegeman at gmail.com
Tue Nov 13 19:08:04 CET 2012
On Mon, Nov 12, 2012 at 9:16 AM, Jurriën Stutterheim
<j.stutterheim at me.com> wrote:
> Hi all,
> foreign import js "%1.push(%2)"
> push :: JSArray a -> a -> IO (JSArray a)
I'm not sure if it's even necessary to extend GHC itself for this.
Even though this exact syntax (with the js calling convention name) is
not supported, the import pattern is available as a string at compile
time , so you can easily generate the desired code with a compiler
that uses the GHC API. I work on GHCJS , a compiler that generates
Unfortunately, GHCJS is in a state of flux at the moment so it's a bit
hard to come up with a proof of concept implementation at this point.
I started a complete rewrite a few months ago, because the old version
didn't have the performance I needed. The new version  appears to
generate much faster code, but a lot of things (including FFI) have
not yet been implemented. It's still a bit too early to tell if the
new code generator can fully replace the old one.
I would like to add the friendlier FFI syntax later, but as far as i
can see, it should be pretty straightforward to do this... (at least
compared to supporting many of the other GHC features in JS)
WebWorkers might not be able to do what you need for concurrency,
since the ways you can communicate between them are really limited,
you have to serialize everything, no shared data. This is why GHCJS
has its own scheduler  in the RTS.
 GHCJS - https://github.com/ghcjs/ghcjs
 GHCJS new code generator - https://github.com/ghcjs/ghcjs/tree/gen2
 GHCJS scheduler -
More information about the Glasgow-haskell-users