Write a parser that consumes a character (or fails if there isn't one) and ensures that character meets a given
predicate. We might also use this parser to write another parser (is
) that parses a specific
character.
satisfy :: (Char -> Bool) -> Parser Char
satisfy p = bindParser character (\c -> if p c then value c else failed)
is :: Char -> Parser Char
is c = satisfy (== c)