futurize / parallel-future

Run Futures in parallel
MIT License
7 stars 0 forks source link

Sequence can run in parallel given a sufficiently smart Task implementation. #4

Open jwoudenberg opened 8 years ago

jwoudenberg commented 8 years ago

Case in point, using the newer version 3.1.0 of data.task the test in this lib runs equally fast using parallel-future or R.sequence.

The trick is that the sequence operation uses a Task's ap method, which combines two tasks (one wrapping a function and one wrapping a value) and returns a third (wrapping the result of calling the function with the value). A simple implementation of ap, for instance one deriving ap from chain, the two initial values are retrieved sequentially. An efficient implementation of ap, like the one in data.task 3.1.0, runs both input tasks in parallel.

Not sure what the consequences of this are for this lib. Should we put a note in the README?

Avaq commented 7 years ago

It has been established in later discussions that parallel ap is actually unlawful in the context of Monads: