Why does my Mapreduce implementation (real world haskell) using iteratee IO also fails with “Too many open files”
问题 I am implementing a haskell program wich compares each line of a file with each other line in the file. Which can be implemented single threaded as follows distance :: Int -> Int -> Int distance a b = (a-b)*(a-b) sumOfDistancesOnSmallFile :: FilePath -> IO Int sumOfDistancesOnSmallFile path = do fileContents <- readFile path return $ allDistances $ map read $ lines $ fileContents where allDistances (x:xs) = (allDistances xs) + ( sum $ map (distance x) xs) allDistances _ = 0 This will run in O