[Haskell-cafe] Parallel interruptible computations
Corentin Dupont
corentin.dupont at gmail.com
Sat Sep 6 10:35:10 UTC 2014
Nobody on those parallel interruptible computations/events?
I believe this is related to FRP: we register on several events but only a
part of them is enough to compute the result.
But I don't see such operator in FRP frameworks such as reactive-banana...
On Fri, Sep 5, 2014 at 12:59 PM, Corentin Dupont <corentin.dupont at gmail.com>
wrote:
> Hi guys!
> I'm wondering if there is an abstraction (for example a typeclass) for
> parallel interruptible computations.
> I want several things to be computed in parallel. Those computations will
> not finish at the same time, but as soon as enough result is gathered, the
> remaining computations can be cancelled and the final result computed.
> Clearly a Monad is not suited here: Monad are by definition for sequential
> computation (since the result of the first computation is fed to the next).
>
> -> So the question is: is there an abstraction for parallel computations?
>
> Note that I'm not interrested with real implementations (such as with
> threads) but with the abstraction.
> For now I came up with:
>
> ShortcutEvents :: [Event a] -> ([a] -> Maybe b) -> Event b
>
> This takes a list of events and a function. The events can fire at
> whatever moment, and as soon as one of the events fires, the function is
> called with the results available so far. If the function returns Just, the
> remaining events are cancelled and the final result is returned.
> This is working fine, but I'd like a way to generalize this, especially to
> generalize the list to any structure...
>
> The use case is a voting system: people can vote at whatever moment, but
> sometime the result of the vote is known even if not everybody voted yet.
>
> Thanks!
> Corentin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140906/2ee9a1a1/attachment.html>
More information about the Haskell-Cafe
mailing list