Wrong result for element check
On the beginners list, Luca Ciciriello reported that
{-# LANGUAGE PArr #-}
{-# OPTIONS -fdph-seq #-}
module Main where
import Control.Parallel
import GHC.PArr
parArr :: [:String:]
parArr = [: "1", "2", "3", "4" :]
isElement :: String -> Bool
isElement x = x `elemP` parArr
main :: IO ()
main = do
putStrLn $ (show . isElement) "5"
prints True. Obviously it should print False. I've replicated the behaviour with 7.0.4 and 6.10.4 on 64-bit linux (Luca tested on Mac and Windows).
As far as I can tell, elemP no longer exists in dph, so I had to modify to test with HEAD, and
{-# LANGUAGE ParallelArrays #-}
{-# OPTIONS -fdph-seq #-}
module Main where
import GHC.PArr
import Data.Array.Parallel
parArr :: [:String:]
parArr = [: "1", "2", "3", "4" :]
isElement :: String -> Bool
isElement x = x `elemP1` parArr
where
elemP1 :: Eq a => a -> [:a:] -> Bool
elemP1 v ar = lengthP (filterP (== v) ar) /= 0
main :: IO ()
main = do
putStrLn $ (show . isElement) "5"
also prints True with HEAD, but prints False with 6.10.4 and 7.0.4 (with the necessary modifications, !ParallelArrays -> PArr, don't import Data.Array.Parallel).
Trac metadata
Trac field | Value |
---|---|
Version | 7.0.4 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Data Parallel Haskell |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |