Write a function that accepts a parser and a function from its produced value to another value to return a parser that potentially produces that value. We will see later why this function is useful.
mapParser :: Parser a -> (a -> b) -> Parser b
mapParser (P p) f = P (\s -> case p s of Just (r, c) -> Just (r, f c)
Nothing -> Nothing)