-
Notifications
You must be signed in to change notification settings - Fork 37
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
Simpler ParFuture #19
Comments
Hi Bas, Thanks for the suggestion! I am perhaps misunderstanding, however: since |
No, do wait <- spawn someExpensiveComputation
doSomethingElse
x <- wait |
Ah, I missed the implications of the changed type. This looks quite promising; my worry is whether we'll be able to make it work with the sparks-based scheduler. We'll have a look this week! |
One disadvantage of this approach is that IVar supports Eq (and could conceivably support Ord), whereas you can't do much with values of type (m a). |
This is neat. We have been thinking of ParFuture as a restricted version of ParIVar, where we spend most of our time. That futures by themselves are obviously an important programming model. I don't see that the above proposal would break anything regarding Par implementations inhabiting both ParFuture, ParIVar, etc. But, I do worry about whether there would be any overheads to constructing extra (m a) objects, or simply confounding the optimizer. We especially want to retain good performance of ParFuture under Control.Monad.Par.Scheds.Sparks. An alternative that we briefly considered was to instead use an associated type with the Par* type classes to get rid of the functional dependency. We mainly backed down from that for an incidental reason -- it would break newtype deriving, which we use heavily in meta-par. Still, it would provide a cleaner interface from the users perspective. P.S. By multiple put error you mean in the case where the 'm' is also in class ParIVar? For the futures only case, using ParFuture alone, there should be no multiple-put opportunity. |
The current
ParFuture
type class is parameterized with both the monadm
and thefuture
. Since the only operation that can be applied to afuture
isget
why not perform that operation insidespawn
so that the user doesn't need to do it and can't accidentallyput
the future twice. This also eliminates the requirement forMultiParamTypeClasses
andFunctionalDependencies
for this type class:(Note I also use this interface in my threads package.)
The text was updated successfully, but these errors were encountered: