Closed dluciv closed 9 years ago
This is a cool idea!
Braindump:
That is what the hplayground monad does
https://github.com/agocorona/hplayground
http://tryplayg.herokuapp.com/
I would be great to have it native in Fay
2014-10-06 13:00 GMT+02:00 Adam Bergmark notifications@github.com:
This is a cool idea!
Braindump:
- Can this be added in a backwards compatible way? With just one Monad we can't detect whether something is a continuation, every non-continuation needs to be wrapped.
- We should probably add a separate continuation ffi function, and change the normal one to just call the success handler to not break code.
- Is there a significant overhead in making everything a continuation?
- Can a compiler flag be added to toggle this? Would that require a separate runtime?
- Your gist seems to be using an old version of fay/runtime.js
— Reply to this email directly or view it on GitHub https://github.com/faylang/fay/issues/414#issuecomment-58001965.
Alberto.
The above comment (on HPlayground) probably describes just the thing wanted, yes! =)
Spring cleaning. Lack of activity, it's unlikely that this will happen.
I could miss something.
Fay provides excellent ffi to access foreign functions. Results of all of them are then wrapped into
Fay
monad and everything looks just the same as for Haskell. But...This all works well for blocking API calls, while JavaScript itself often relies on continuation passing style that it alike Haskell's one except callback invokation order. Genuine Haskell invokes blocking POSIX (and so on) API and it looks as a pain (Haskell looks too advanced for such a legacy environment). JavaScript asynchroneous APIs do look much more natural to be integrated with Haskell.
For Fay (and for any other Haskell-JavaScript compiler too) it is very sad to use API in following way (excample from
fay-dom
source):For Haskell it could be much more natural to write:
There are a lot of other examples surely. At least, all Node.js input is handled similarly. Here is what can be done. But why we need palying with
Cont
monad and in the same time havingFay
monad already handling the callbacks (just because it is a monad)?..Can we upgrade ffi and
Fay
>>=
operator in some way to make this built-infeature and reduce such an overhead?