Say I have a lazy Tree whose leaves are possible solutions to the problem
data Tree a = Node [Tree a] | Leaf (Maybe a)
I need to find only one solution (or find out that it is not).
I have a P-nuclear machine. Based on considerations of the efficient use of time and memory, it makes sense to search simultaneously for P different branches.
For example, suppose you have four branches of approximately the same computational complexity (corresponding to T seconds of processor time), and each of them has an answer.
If you evaluate all four branches truly in parallel on a dual-core machine, then they will all end in about 2T seconds.
If you evaluate only the first two branches and set aside the other two, you will get an answer in only T seconds, also using half as much memory.
My question is, is it possible to use any of the Haskell parallel infrastructure (Par monad, parallel Strategies, ...) for this, or do I need to use lower level tools like async?
source share