Haskell Fay sequential asynchronous calls

I recently decided to port some javascript code to Fay so that I can ensure that the font is correct and so that I can handle async in a neat way (and also experiment). I created several javascript objects whose sole purpose was to synchronize concurrent ajax calls. I am new to Haskell.

In Fay, I was hoping to strip away a few ajax calls and use, say, Control.Monad.Parallel.sequence to make them syncronized. However, I am stuck and desperate for a tutorial because fay-jquery AJAX functions do not return a monad for success / failure callbacks, and this example in fay snaplet does too. They all return the monad Fay (), which seems to be for ordering Hackell's lazy calls into strict javascript expressions together, whereas I was sort of expecting something like a tuple (Fay (), IO (or SuccessResult FailureResult)) since firing off the AJAX request results in two different actions.

I have many questions about this:

Replies will be much appreciated! They will be of immense help to my shaky understanding of this material.

+3


source to share


1 answer


  • Yes. The Cont example practically does what you want with no error handling.
  • ^
  • It depends on your definition of "unclean". I would say that the function returned before all of its effects can be clean. This applies to almost all lazy evaluation in Haskell. see for example HaskellforkIO :: IO () -> IO ThreadId

  • I'm not sure what you mean by "in Fay itself". I don't think Prelude should use this, but other libraries can use Cont, and if you want that doesn't do the package from the example.


+2


source







All Articles