Take the 2-minute tour ×

What is this error?

Couldn't match expected type Eval [a]' against inferred type()

module Main where   

import Control.Parallel(par,pseq)   
    import Text.Printf   
    import Control.Exception   
    import System.CPUTime   
    import Data.List   
    import IO   
    import Data.Char   
    import Control.DeepSeq  
    import Control.Parallel.Strategies 

--Calcula o tempo entre o inicio e o fim de rodagem do programa   
    time :: IO t -> IO t   
    time a = do   
        start <- getCPUTime   
        v <- a 
        end   <- getCPUTime   
        printf "Computation time: %0.3f sec\n" (diff :: Double)   
        return v   

learquivo :: FilePath -> IO ([[Int]])   
    learquivo s = do    
                conteudo <- readFile s    
                return (read conteudo)    

main :: IO ()   
    main = do    
        t1 <- getCPUTime  
        conteudo <- learquivo "list.txt"  
        let !mapasort = (map qsort conteudo) `using` (parList rdeepseq)  
        t2 <- getCPUTime  
        let difft2t1 = (fromIntegral (t2 -t1)) / (10^12)  
        printf "Computation time %0.3f sec" (difft2t1 :: Double)  

qsort [] = []  
    qsort [x] = [x]  
    qsort (x:xs) =  
`           losort ++ (x:hisort) `using` strategy  `
            losort = qsort [y|y <- xs, y < x]  
            hisort = qsort [y|y <- xs, y >= x]  
            strategy result = rnf losort `par`  
                        rnf hisort `pseq`  
                        rnf result
share|improve this question
I don't have time right now, but try to isolate the problem by creating a file with the definition for strategy and whatever dependencies it requires. It may give a better error message. –  Ionuț G. Stan Nov 11 '10 at 12:44
Help us out by marking line 41 for us. –  dave4420 Nov 11 '10 at 13:04
The error is in losort ++ (x:hisort) ``using`` strategy –  sastanin Nov 11 '10 at 13:25
add comment

1 Answer

up vote 5 down vote accepted

Probably the problem is that you are using rnf from the Control.Deepseq


which is coincidentally the strategy in terms of parallel < 2.2:

type Strategy a = a -> ()   -- strategy type in early parallel package

but since version 2.2 of parallel, strategies have a different type:

type Strategy a = a -> Eval a

P.S. Latest version of parallel is You may consider reading the complete history of API revisions. As far as I understand, the latest API version is explained in Seq no More: Better Strategies for Parallel Haskell paper.

share|improve this answer
add comment

Your Answer


