Parallel map in haskell

前端 未结 2 1549
既然无缘
既然无缘 2020-12-13 06:49

Is there some substitute of map which evaluates the list in parallel? I don\'t need it to be lazy.

Something like: pmap :: (a -> b) -> [a] -

2条回答
  •  感动是毒
    2020-12-13 07:30

    Besides using explicit strategies yourself as Tom has described, the parallel package also exports parMap:

     parMap :: Strategy b -> (a -> b) -> [a] -> [b]
    

    where the strategy argument is something like rdeepseq.

    And there's also parMap in the par-monad package (you step out of pure Haskell, and into a parallel monad):

     parMap :: NFData b => (a -> b) -> [a] -> Par [b]
    

    The par-monad package is documented here.

提交回复
热议问题