[Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?

Adam Bergmark adam at edea.se
Wed Sep 4 21:29:22 CEST 2013


Niklas: I missed your note about calling Haskell from JS, see this for Fay:
https://github.com/faylang/fay/wiki/Fay-Status-Update-September-2013%3A-ZuriHac%2C-typeclasses%2C-haskell-suite%2C-and-strictness-wrappers#javascript-fay-communication



On Wed, Sep 4, 2013 at 8:18 PM, Luite Stegeman <stegeman at gmail.com> wrote:

>
> On Wed, Sep 4, 2013 at 6:32 PM, Daniil Frumin <difrumin at gmail.com> wrote:
>
>>
>>
>> I think it's nice that you've raised that question, I will think about
>> implementing a finer API for calling Haskell from JS.
>>
>>
> It sounds like something like h$runSyncWithResult (name open for
> bikeshedding) that takes an IO (JSRef a) and returns the result to the
> caller, or null (exception?) when the synchronous thread terminated for
> some reason, would fit the bill. I think this can be implemented in a few
> lines of JS.
>
> the current API is a bit bare-bones, based around calling main or a few
> other top-level IO actions and doing the rest from Haskell code. The
> Haskell code can make callbacks (JS functions that run Haskell when called,
> see [1] ), but that can be a bit cumbersome to use when wrapping a library
> with lots of external JavaScript.
>
> If anyone has ideas of how they'd like a call-Haskell-functions-from-JS
> API to look, I'd be happy to hear and see if we can make something nice.
>
> One thing to keep in mind though is that type information has been erased
> from the compiled code, making a generic applyHaskellFun(fun,x,y) that
> would run 'fun x y' and return its result would be rather risky. That's why
> the syncCallback/asyncCallback actions use JSRef, letting the Haskell side
> do the conversion. Going through 'foreign export' could work though, or
> perhaps there are other options that make this safer.
>
> luite
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130904/fcff088d/attachment.htm>


More information about the Haskell-Cafe mailing list