I'm using the parsing library Parsec to parse some text.
I simply need to parse lines, which are strings of arbitrary characters, ending with a '\n' or an eof when its at the end of the string.
When calling parseHS'
I get the complaint that Exception: Text.ParserCombinators.Parsec.Prim.many: combinator 'many' is applied to a parser that accepts an empty string.
.
parseHS' :: String -> Either ParseError [String]
parseHS' input = parse hsFile' "(unknown)" input
hsFile' :: GenParser Char st [String]
hsFile' = do
many1 line
line :: GenParser Char st String
line = do
result <- many (noneOf "\n")
optional newline
return result
How could this be achieved correctly?
noneOf
doesn't accept an empty string. Are you sure you don't have amany line
somewhere else in your code ? – Tarmil