Testsuite: tabs -> spaces [skip ci]
[ghc.git] / testsuite / tests / dph / words / Main.hs
1
2 import WordsVect
3 import Data.Array.Parallel
4 import qualified Data.Array.Parallel.Prelude.Word8 as W
5 import qualified Data.Array.Parallel.PArray as P
6 import qualified Data.Array.Parallel.Unlifted as U
7 import Data.Char
8
9 main
10 = do -- take the filename containing the words as the first arg
11 let str = "When I look into the looking glass I'm always sure to see"
12 ++ " no matter how I dodge about, me looking back at me."
13
14 -- convert string to a PArray
15 let paStr :: PArray W.Word8
16 paStr = P.fromUArray $ U.map W.fromInt $ U.fromList $ map ord str
17
18
19 -- break the string into words then flatten it back
20 let str' :: String
21 str' = map chr
22 $ map fromIntegral
23 $ P.toList
24 $ wordsOfPArray paStr
25
26
27 -- count the number of words in the string, using the vectorised program
28 let wordCountVect = fromIntegral $ wordCountOfPArray paStr
29
30 -- count the number of words with the ye'olde list way
31 let wordCountList = length $ words str
32
33 --
34 putStr $ show str' ++ "\n"
35 ++ "word count vect = " ++ show wordCountVect ++ "\n"
36 ++ "word count lists = " ++ show wordCountList ++ "\n"
37