Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Control/Parallel/Strategies.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ module Control.Parallel.Strategies (
-- * Strategies for traversable data types
, evalTraversable -- :: Traversable t => Strategy a -> Strategy (t a)
, parTraversable
, parFmap

-- * Strategies for lists
, evalList -- :: Strategy a -> Strategy [a]
Expand Down Expand Up @@ -615,6 +616,14 @@ chunk n xs = as : chunk n bs where (as,bs) = splitAt n xs
parMap :: Strategy b -> (a -> b) -> [a] -> [b]
parMap strat f = (`using` parList strat) . map f


-- | A generalisation of 'parMap' using 'parTraversable' and `fmap`:
--
-- > parFmap strat g = withStrategy (parTraversable strat) . fmap f
--
parFmap :: Traversable t => Strategy b -> (a -> b) -> t a -> t b
parFmap strat f = (`using` parTraversable strat) . fmap f

-- --------------------------------------------------------------------------
-- Strategies for lazy lists

Expand Down