我正在使用解析库 Parsec 来解析一些文本。我只需要解析行,它们是任意字符的字符串,在字符串末尾时以 '\n' 或 eof 结尾。打电话时parseHS'
我得到的投诉是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
如何正确实现这一目标?