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


def optional_parser(
	sub_parser: Callable[[str], Optional[Tuple[str, str]]], text: str
) -> Optional[Tuple[str, str]]:
	"""
	changes a parser by making it never return Nothing,
	that is it makes the parser optional.
	"""
	result = sub_parser(text)
	if result is None:
		return ("", text)  # return text unconsumed
	else:
		return result