【发布时间】:2012-06-16 20:10:39
【问题描述】:
我想将整个文件读入一个字符串,然后使用函数lines 来获取字符串的行。我正在尝试使用这些代码行:
main = do
args <- getArgs
content <- readFile (args !! 0)
linesOfFiles <- lines content
但我通过编译失败的广告得到以下错误:
Couldn't match expected type `IO t0' with actual type `[String]'
In the return type of a call of `lines'
In a stmt of a 'do' block: linesOfFiles <- lines content
我认为通过将readFile 的结果绑定到内容,它将是String 数据类型,为什么不是?
【问题讨论】: