from typing import Callable
from typing import Optional
from typing import Tuple


def then_parser(
	first_parser: Callable[[str], Optional[Tuple[str, str]]],
	second_parser: Callable[[str], Optional[Tuple[str, str]]],
	text: str,
) -> Optional[Tuple[str, str]]:
	"""
	Uses one parser on the text,
	then uses the next parser on the remaining
	text from the first parse.
	"""
	first_result = first_parser(text)
	if first_result is None:
		return None
	else:
		parsed, rest = first_result
		second_result = second_parser(rest)
		if second_result is None:
			return None
		else:
			parsed_2, rest_2 = second_result
			return parsed + parsed_2, rest_2