2015-01-02

Posted on January 2, 2015

With some tweaking, I’ve generalized the ajax function in GHCJS-jQuery to do what I need (I’ll have to tidy this up with a typeclass at some point). However, what I seem to be seeing is that after (successfully) making an ajax call, nothing else happens. I think I need a tiny test case to examine this: it’s possible that a judicious forkIO may solve the problem; otherwise I guess there may be a bug in GHCJS-jQuery.

Well, that’s irritating. My tiny test case doesn’t exhibit the problem, but even after a simplifying the real todo code a bit, it’s still failing to run anything after the ajax call. Doesn’t matter if I use the original ajax, or my own ajax2. Ah, now, of course a major difference is that in the todo app the code is running in an on callback. What happens if I duplicate that?

Yes, that demonstrates the problem. Now, I can indeed make things work again by putting the ajax call into a forkIO; the only hitch with doing so is that the result of the ajax is within the forked thread. That means I’ll have to do some kinda async exception handling.

Aha! Setting hsSynchronous = False on the click handler seems to avoid the problem.

Also, from the IRC channel:

<hamishmack> toby1851: Could it be this recently fixed issue?  https://github.com/ghcjs/ghcjs/issues/291
<hamishmack> If you run that test code and it fails then it probably is
 I think the bug only existed a few days before Luite fixed it again, but it does sound very similar
<hamishmack> toby1851: If that is what it is then you should be able to get the fix by doing cd ~/.ghcjs/x86_64-darwin-0.1.0-7.*/ghcjs/shims && git pull

Yes, hamishmack was right. So, I haven’t quite finished the toodo app, but it’s fairly obvious where it goes from here; as far as evaluating GHCJS goes, I don’t really need to complete the grunt work.

The question is: what next?

Well, I’m not going back to ember! I do want to continue with GHCJS, although with plain jQuery there’s a lot of housekeeping going on. I suppose I should take another look around and see if there’s anything I’ve missed. If not, then I’ll see if I can write something to abstract some of the pain of the bindings away.

That would probably start life in the good ol’ todo app, but eventually I need to start working on the real flare code. I do wonder about going straight to the messages, although the argument that I should do the conf stuff first to gain experience still holds weight.