phoneParser

We will use the phoneBodyParser and the is parser to create a parser for the phone number. Once again, we glue it all together using bindParser and mapParser. Notice that we ignore the hash character in the end when we produce the final string.

phoneParser :: Parser String
phoneParser = bindParser digit (\d -> bindParser phoneBodyParser (\z -> mapParser (is '#') (\_ -> d : z)))

Phone: string of digits, dots or hyphens but must start with a digit and end with a hash (#)