from typing import Callable
import posixpath


def _next_path(current_path: str) -> Callable[[str], str]:
    """Factory for updating path.

    Example:
    ```
    get = _next_path("/foo")
    get("bar")
    >>> "/foo/bar"
    ```
    """

    def _wrap(segment: str):
        return posixpath.join(current_path, segment)

    return _wrap