Reputation: 616
I have a file with multiple list of (String,String,Int):
[("aaa","aaaaaaaa",13),("asdasdasd","asdea",13)]
and I need to store it in a variable, I have this:
xfx = do {
text <- readFile "textlist";
let
x=3 -- nothing
in function text
}
But function receives Char instead of that data type.
Upvotes: 0
Views: 631
Reputation: 363487
If the file contains only one list, then you can just call read
on the result of readFile
:
parseFile :: IO [(String,String,Int)]
parseFile = do s <- readFile "textlist"
return (read s)
Upvotes: 1