Implement MonadPar and MonadRace#62
Implement MonadPar and MonadRace#62jdegoes merged 5 commits intopurescript-contrib:masterfrom garyb:monadpar
Conversation
|
@garyb There does have to be an AVAR, although it could be REF or something, as combined with Aff, it has the right connotation (mutable variable). |
|
Ah true, I forgot about that as we mostly use the How do you feel about moving |
|
I don't terribly mind moving �Can't one FFI module import another FFI module? |
src/Control/Monad/Aff.purs
Outdated
|
|
||
| foreign import _killVar :: forall e a. Fn3 (Canceler e) (AVar a) Error (Aff e Unit) | ||
|
|
||
| -------------------------------- |
There was a problem hiding this comment.
We can indeed pull in cross-FFI-module dependencies, but we still need to replicate some of the AVar interface in Aff. It's not exported though, so maybe that's fine?
|
It's pretty neat that I could just swap |
src/Control/Monad/Aff.js
Outdated
| }; | ||
|
|
||
|
|
||
| var avar = require("../Control.Monad.Aff.AVar/foreign.js"); |
There was a problem hiding this comment.
Won't this break if you are using psc-bundle without browserify?
There was a problem hiding this comment.
I don't think pulp test uses browserify, and it succeeds there, so no, I think it's ok. I was concerned about that too... I'm still a little suspicious, but it seemed to work for the cases I tested. I'll try with psc-bundle directly to ensure there isn't some magic in pulp.
There was a problem hiding this comment.
I think pulp test just runs it in node (no bundling), so it would work. But I don't think psc-bundle will follow this reference, and you'll end up with a stray require for it.
There was a problem hiding this comment.
Hmm, it doesn't exactly work. It works in node if the planets align correctly, as the require is resolved by node instead... but the bundle isn't browser-safe at that point, so yeah, this probably isn't going to work.
|
I've just pushed another set of changes that should address the FFI problems. This time we have an |
|
I think this looks good. You could also push the |
|
We'd end up with the orphan instance issue I'm trying to avoid again there though! Unless we made |
|
Oh, right! Then I think what you've done is fine. |
|
@garyb This looks pretty good. Any breaking (public) API changes? |
|
I think the removal of I could reinstate |
Will resolve #60.
So this definitely seems straightforward enough, apart from the minor problem of needing to move
AVarinto the mainAffmodule, unless we want to implement a load of stuff in the FFI. We end up with a circular dependency between theAffandAVarmodules otherwise, as the instances have to be defined inAff, and theAVarmodule depends on theAffmodule.Another thought, while we're at it, does there actually need to be an
AVAReffect? It doesn't really tell you much about what might occur, other than there's some "advanced" async behaviour going on, butAffimplies async anyway. I ask as apart from it being common thatAVARappears in everyAffeffect row for non-trivial uses, it actually has to be hidden forMonadParandMonadRaceas we can't specify it in the instance head, no rows are allowed there. Hence theeraseAVarusage here.This isn't ready for merge yet, as I just dumped the
AVarstuff intoAff, it's not sorted out properly yet.