async icon indicating copy to clipboard operation
async copied to clipboard

Semigroup and Monoid instances for ConcurrentlyE

Open danidiaz opened this issue 4 years ago • 0 comments

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?

danidiaz avatar Nov 13 '21 18:11 danidiaz