【发布时间】:2014-10-17 11:44:26
【问题描述】:
我是 Haskell 的初学者。在此任务中,我正在执行拆分操作,但由于类型不匹配而面临问题。我正在从文本文件中读取数据,数据是表格格式。前任。 1|2|Rahul|13.25. 采用这种格式。这里| 是定界符,所以我想从定界符| 中拆分数据,并想打印第二列和第四列数据,但我收到这样的错误
"Couldn't match type `[]' with `IO'
Expected type: IO [Char]
Actual type: [[Char]]
In the return type of a call of `splitOn'"
这是我的代码..
module Main where
import Data.List.Split
main = do
list <- readFile("src/table.txt")
putStrLn list
splitOn "|" list
对此的任何帮助将不胜感激..谢谢
【问题讨论】: