from typing import Tuple
from typing import Any


def replace_value_by_index(xs: Tuple[Any, ...], pos: int, value: Any) -> Tuple[Any, ...]:
    """
    Return a new instance of the tuple replacing the specified
    position with the new value.

    :param xs: A tuple.
    :param pos: Zero-based index of the item which should be replaced.
    :param value: New value.
    """
    return tuple(value if idx == pos else elem for idx, elem in enumerate(xs))