"""Result types — Ok/Err for explicit success/failure return values."""

from __future__ import annotations

from typing import Generic, TypeVar, Union

T = TypeVar("T")
E = TypeVar("E")


class Ok(Generic[T]):
    __slots__ = ("value",)

    def __init__(self, value: T) -> None:
        self.value = value

    def __repr__(self) -> str:
        return f"Ok({self.value!r})"


class Err(Generic[E]):
    __slots__ = ("reason",)

    def __init__(self, reason: E) -> None:
        self.reason = reason

    def __repr__(self) -> str:
        return f"Err({self.reason!r})"


Result = Union[Ok[T], Err[E]]
