[Haskell-cafe] Tutorial on JS with Haskell: Fay or GHCJS?
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:
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  ), but that can be a bit cumbersome to use when wrapping a library
> 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.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe