We will break the parsing of a phone number into two parts for simplicity. This part will parse the phone number
body (without the hash at the end). It uses the list
, digit
and is
parsers
along with choice.
phoneBodyParser :: Parser String
phoneBodyParser = list (digit ||| is '.' ||| is '-')
Phone: string of digits, dots or hyphens but must start with a digit and end with a hash (#)