I am looking for a satisfy function like the one Parsec has. Something like:
--The parser satisfy f succeeds for any character for which the supplied
--function f returns True.
--Returns the character that is actually parsed.
satisfy :: (Char -> Bool) -> Parser Char
The only thing I have found is pSatisfy, which requires an Insertion as argument. I don't understand why this is necessary... I just want the parser to fail in case the predicate is not satisfied!
How can I achieve this?
Finally I managed to hack up a
satisfyfunction which meeted my needs. However, uu-parsinglib is an error correcting parser and will throw an exception in case you don't provide a correcting alternative.This means you should use the normal
pSatisfyfunction and provide anInsertionelement. If you are not sure about what the cost should be you can use 5, as seen in the implementations of other parsers likepSymbol.