For example
parseTest :: Parser Int
parseTest = char '(' *> return 1 <* char ')'
parseTests :: Parser [Int]
parseTests = many' $ char '(' *> return 1 <* char ')'
parseOnly ParseIni.parseTest "(" -- returns Left with error
parseOnly ParseIni.parseTests "(" -- returns Right with []
How can I make the second one to return Left with lost ), and I also want to parse the case with empty string with answer Right []
From the doc on
parseOnlyParseIni.parseTestsapplies the parserchar '(' *> return 1 <* char ')'zero or more times. It always succeeds, as it can at least apply it zero times. Thus you need to ensure it consumed everything by composing it withendOfInput.