当我尝试解析 many p
时,我没有收到“期待 p”消息:
> parse (many (char '.') >> eof) "" "a"
Left (line 1, column 1):
unexpected 'a'
expecting end of input
相比于
> parse (sepBy (char '.') (char ',') >> eof) "" "a"
Left (line 1, column 1):
unexpected 'a'
expecting "." or end of input
报告“。” 正如我所料。many1 p <|> return []
也可以。
所有这些函数都接受空输入,那么为什么不many
报告它所期望的呢?它是错误还是功能?