Haskell parTraversable不产生任何火花

Haskell parTraversable不产生任何火花,haskell,parallel-processing,Haskell,Parallel Processing,当我使用-s运行此程序时: module Main where import Control.Parallel.Strategies main :: IO () main = do let xs = take 1000 $ product . take 1000 . repeat <$> [1..] x = product (xs `using` parList rseq) putStrLn (show x) 不会产生火花: 火

当我使用
-s
运行此程序时:

module Main where

import Control.Parallel.Strategies

main :: IO ()
main = do let xs = take 1000 $ product . take 1000 . repeat <$> [1..]
              x  = product (xs `using` parList rseq)
          putStrLn (show x)
不会产生火花:

火花:0(0转换,0溢出,0无效,0 GC'd,0失效)

如果我将
rseq
更改为
rdeepseq

main = do let xs = (take 1000 $ product . take 1000 . repeat <$> [1..]) :: [Integer]
              x  = product (xs `using` parList rdeepseq)
          putStrLn (show x)

我遗漏了什么?

我可以重现你的行为(ghc-8.2.1,parallel-3.2.1.1)

稍后往下看
Strategies.hs
是一个
RULES
pragma,表示特殊情况
parList-rseq
。我猜这是一个bug,它与parTraversable有不同的行为(我对内部结构了解不够,无法确定bug的位置)。我建议在
parallel
issue tracker提交一张罚单:

以下是有问题的代码,从文件的第505行开始:

-- Non-compositional version of 'parList', evaluating list elements
-- to weak head normal form.
-- Not to be exported; used for optimisation.

-- | DEPRECATED: use @'parList' 'rseq'@ instead
parListWHNF :: Strategy [a]
parListWHNF xs = go xs `pseq` return xs
  where -- go :: [a] -> [a]
           go []     = []
           go (y:ys) = y `par` go ys

-- The non-compositional 'parListWHNF' might be more efficient than its
-- more compositional counterpart; use RULES to do the specialisation.

{-# NOINLINE [1] parList #-}
{-# NOINLINE [1] rseq #-}
{-# RULES
 "parList/rseq" parList rseq = parListWHNF
 #-}
parList :: Strategy a -> Strategy [a]
parList = parTraversable
-- Non-compositional version of 'parList', evaluating list elements
-- to weak head normal form.
-- Not to be exported; used for optimisation.

-- | DEPRECATED: use @'parList' 'rseq'@ instead
parListWHNF :: Strategy [a]
parListWHNF xs = go xs `pseq` return xs
  where -- go :: [a] -> [a]
           go []     = []
           go (y:ys) = y `par` go ys

-- The non-compositional 'parListWHNF' might be more efficient than its
-- more compositional counterpart; use RULES to do the specialisation.

{-# NOINLINE [1] parList #-}
{-# NOINLINE [1] rseq #-}
{-# RULES
 "parList/rseq" parList rseq = parListWHNF
 #-}