I'm trying to make some simple modifications to a program from Real World Haskell Chapter 24. Here's some code that counts the number of lines in a file:
import qualified Data.ByteString.Lazy.Char8 as LB
lineCount :: [LB.ByteString] -> Int64
lineCount = mapReduce rdeepseq (LB.count '\n')
rdeepseq sum
I'm trying to write some code that counts the words in the file. Here's what I came up with:
import qualified Data.ByteString.Lazy.Char8 as LB
lineCount :: [LB.ByteString] -> Int64
lineCount = mapReduce rdeepseq (length LB.words)
rdeepseq sum
However, I get:
Couldn't match expected type `LB.ByteString -> b0'
with actual type `Int'
In the return type of a call of `length'
Probable cause: `length' is applied to too many arguments
In the second argument of `mapReduce', namely `(length LB.words)'
In the expression:
mapReduce rdeepseq (length LB.words) rdeepseq sum
What could be the problem?