[Haskell-cafe] Evaluating parallel computations in order of finishing (approximately)

Victor Miller victorsmiller at gmail.com
Mon Feb 6 23:46:44 CET 2012


Suppose that we have a list [a] of computations that we want to evaluate in
parallel.  I would like to have something (probably a monad) which would
return the list in order (roughly) of finishing:

Say the monad is M.  It would be something like the state monad, in that it
would be implemented by a state transformer function.  In this case the
state would the set of computations to be evaluated.

we might have a function


include :: [a] -> M a ()

which would say that the monad's responsibility would be to evaluate all
the members of a in parallel.  We might also have a function

strategy :: Strategy -> M a ()

which would indicate the parallel strategy to be used.

The key thing would be function, completed, which produces a list of all
the computations to be evaluated as a list roughly in order of completion.

That is, if, inside the M monad we finished the do with

completed

then we would have a value M a [a]

which would be the list in order of completion.

Since everything is lazy we could ask for the head of the list, and it
would be the first value whose computation finished.

Does such a thing exist?


Victor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120206/8df6f3aa/attachment.htm>


More information about the Haskell-Cafe mailing list