Add parallel apply - #20
Conversation
| => m (a -> b) | ||
| -> m a | ||
| -> m b | ||
| parApply mf ma = apply (parallel mf) (parallel ma) # sequential |
There was a problem hiding this comment.
Please use parens rather than (#) here.
| import Data.Foldable (class Foldable, traverse_, oneOfMap) | ||
| import Data.Traversable (class Traversable, traverse) | ||
|
|
||
| parApply |
There was a problem hiding this comment.
Could you please add a comment?
| -> m b | ||
| parApply mf ma = apply (parallel mf) (parallel ma) # sequential | ||
|
|
||
| infixl 4 apply as <!> |
There was a problem hiding this comment.
This choice of name seems a bit arbitrary. Now, I'll admit, it's no more arbitrary than <*> or the recently added <@>, but I wonder if we need it at all. I might even just use parApply as an infix function if I need this.
There was a problem hiding this comment.
I agree it's pretty arbitrary. Personally I feel that an operator would provide a lot of value, but I'm ready to just define that in my own projects as an alias, if we choose not to include this :)
There was a problem hiding this comment.
I would rather not claim this name in a core library for something which the user can alias themselves.
|
Another option would be to include a newtype for things that are We basically had that before, but before there was a class... or something. I forget now. |
|
Well, the functional dependency implements the type function that gives you the applicative you want, it's just not a newtype necessarily. |
|
So how would you like to move forward with this? :) |
|
If you could remove the operator for now, I'll merge this. Thanks! |
|
Thanks! |
Adds a new function and operator (open for bike shedding on a more fitting operator) for parallel application. Would allow us to write:
instead of: