module Main where import MapReduce (mapReduce) import Data.List.Split (splitOn) wordCount = mapReduce mapper reducer where mapper (_, sentence) = map (\word -> (word, 1)) (splitOn " " sentence) reducer (word, counts) = (word, sum counts) main = do mapM_ (\(word, count) -> putStrLn $ show count ++ " " ++ word) (wordCount input) where input = [ ("gravity", "a screaming comes across the sky"), ("1984", "it was a bright cold day in april and the clocks were striking thirteen"), ("neuro", "the sky above the port was the color of television tuned to a dead channel") ]