-
Notifications
You must be signed in to change notification settings - Fork 65
Implement MonadPar and MonadRace #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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? |
|
||
foreign import _killVar :: forall e a. Fn3 (Canceler e) (AVar a) Error (Aff e Unit) | ||
|
||
-------------------------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
@@ -320,3 +320,11 @@ exports._tailRecM = function (isLeft, f, a) { | |||
}(a); | |||
}; | |||
}; | |||
|
|||
|
|||
var avar = require("../Control.Monad.Aff.AVar/foreign.js"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this break if you are using psc-bundle without browserify?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
AVar
into the mainAff
module, unless we want to implement a load of stuff in the FFI. We end up with a circular dependency between theAff
andAVar
modules otherwise, as the instances have to be defined inAff
, and theAVar
module depends on theAff
module.Another thought, while we're at it, does there actually need to be an
AVAR
effect? It doesn't really tell you much about what might occur, other than there's some "advanced" async behaviour going on, butAff
implies async anyway. I ask as apart from it being common thatAVAR
appears in everyAff
effect row for non-trivial uses, it actually has to be hidden forMonadPar
andMonadRace
as we can't specify it in the instance head, no rows are allowed there. Hence theeraseAVar
usage here.This isn't ready for merge yet, as I just dumped the
AVar
stuff intoAff
, it's not sorted out properly yet.