我是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'"
Run Code Online (Sandbox Code Playgroud)
这是我的代码..
module Main where
import Data.List.Split
main = do
list <- readFile("src/table.txt")
putStrLn list
splitOn "|" list
Run Code Online (Sandbox Code Playgroud)
任何关于此的帮助将表示赞赏..谢谢