This seems so simple, but for some reason I’m confusing myself. The “thing” line is giving me the error.
The parsing functions are correct (stolen from RWH). I just have a type error.
Thanks!
import Text.ParserCombinators.Parsec
import System.IO
main = do
csv_cont <- openFile "aCSV.txt" ReadMode
csv_cont1 <- hGetContents csv_cont
thing <- parseCSV csv_cont1
return ()
csvFile = endBy line eol
line = sepBy cell (char ',')
cell = many (noneOf ",\n")
eol = char '\n'
parseCSV :: String -> Either ParseError [[String]]
parseCSV input = parse csvFile "(unknown)" input
parseCSVis a pure function (note, noIOin the type). So you don’t use “do notation” to bind its result. Instead, just regularletis appropriate:Here, with more idiomatic naming and identation.