Portability | unportable |
---|---|
Stability | stable |
Maintainer | Martin Avanzini <martin.avanzini@uibk.ac.at> |
Safe Haskell | Safe-Infered |
This module provides implements parallel folding of associative operators, and some convenience utilities implemented on top of it.
- pfold :: (a -> b -> a) -> a -> [IO b] -> IO a
- pfoldA :: (a -> b -> Return a) -> a -> [IO b] -> IO a
- data Return a
- fastest :: a -> [IO a] -> IO a
- fastestSatisfying :: (a -> Bool) -> a -> [IO a] -> IO a
- alt :: IO a -> [IO a] -> IO a
- choice :: IO a -> IO a -> IO a
- par :: IO a -> IO b -> IO (a, b)
- (<+>) :: forall a b. IO a -> IO b -> IO (a, b)
- (<|>) :: forall a. IO a -> IO a -> IO a
Documentation
The call 'pfold f a ms' executes the io actions ms in
parallel, and collects the results of using the function
f
and the initial value a
. No guarantee on the order
of the folding is given, and thus f
should be associative.
If an io action from ms
receives an uncought exception,
then the specific io action is silently ignored.
Same as pfold
but allows the folding operator to abort
the computation and return a result immediately. All pending
spawned io actions are cilled.
The result type of the folding function for the pfoldA
.
Utilities Implemented on top of pfold
The following actions are all implemented on top of
pfoldA
, hence again actions that receive an uncaught
exception are silently ignored
The call 'fastest a ms' executes the io actions ms
in parallel,
and returns the first computed result, or a
if the io actions ms
are empty.
fastestSatisfying :: (a -> Bool) -> a -> [IO a] -> IO a
Same as fastest, but additionally checks a predicate on the returned result. If the predicate does not hold, the result is discarded.
The call 'alt m ms' executes all actions in 'm:ms' in parallel, and returns the fastest computed result.
'choice a b == alt a [b]'
'par ma mb' runs the action ma
and mb
in parallel, returning their result.
The actions ma
and mb
need to properly catch all exceptions, or otherwise
the call might hang indefinately
Infix version of par
.
Infix version of choice
.