The surname parser requires us to piece together the upper
, thisMany 5 lower
and
list lower
parsers. Again, we do this using bindParser
and mapParser
.
surnameParser :: Parser String
surnameParser = bindParser upper (\c -> bindParser (thisMany 5 lower) (\cs -> mapParser (list lower) (\t -> c : cs ++ t)))
Surname: string that starts with a capital letter and is followed by 5 or more lower-case letters