simonmar / async

Run IO operations asynchronously and wait for their results
BSD 3-Clause "New" or "Revised" License
323 stars 65 forks source link

Semigroup and Monoid instances for ConcurrentlyE #126

Closed danidiaz closed 1 year ago

danidiaz commented 3 years ago

Added Semigroup and Monoid instances for ConcurrentlyE. They work by returning either the combination of the successes or the first failure. When the error type is Void—that is, impossible—they are equivalent to those of normal Concurrently.

The Monoid / Applicative instances for ConcurrentlyE can be useful to solve tasks like this one (taken from Reddit):

I wonder how I could evaluate a list "xs :: [IO (Maybe Int)]" in parallel and return just the first element which returns a "Just result" value after evaluation?