【发布时间】:2013-03-03 03:04:55
【问题描述】:
我正在尝试对 Real World Haskell 第 24 章中的程序进行一些简单的修改。下面是一些计算文件中行数的代码:
import qualified Data.ByteString.Lazy.Char8 as LB
lineCount :: [LB.ByteString] -> Int64
lineCount = mapReduce rdeepseq (LB.count '\n')
rdeepseq sum
我正在尝试编写一些代码来计算文件中的单词。这是我想出的:
import qualified Data.ByteString.Lazy.Char8 as LB
lineCount :: [LB.ByteString] -> Int64
lineCount = mapReduce rdeepseq (length LB.words)
rdeepseq sum
但是,我得到:
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
可能是什么问题?
【问题讨论】: