# Path: oslash/either.py
# class Right(Either[TSource, TError]):
# 
#     """Represents a successful computation."""
# 
#     def __init__(self, value: TSource) -> None:
#         self._value = value
# 
#     # Functor Section
#     # ===============
# 
#     def map(self, mapper: Callable[[TSource], TResult]) -> Either[TResult, TError]:
#         result = mapper(self._value)
#         return Right(result)
# 
#     # Applicative Section
#     # ===================
# 
#     @classmethod
#     def pure(cls, value: Callable[[TSource], TResult]) -> "Right[Callable[[TSource], TResult], TError]":
#         return Right(value)
# 
#     def apply(
#         self: "Right[Callable[[TSource], TResult], TError]", something: "Either[TSource, TError]"
#     ) -> "Either[TResult, TError]":
#         def mapper(other_value):
#             try:
#                 return self._value(other_value)
#             except TypeError:
#                 return partial(self._value, other_value)
# 
#         return something.map(mapper)
# 
#     # Monad Section
#     # =============
# 
#     @classmethod
#     def unit(cls, value: TSource) -> "Right[TSource, TError]":
#         return Right(value)
# 
#     def bind(self, func: Callable[[TSource], Either[TResult, TError]]) -> Either[TResult, TError]:
#         return func(self._value)
# 
#     # Operator Overloads
#     # ==================
# 
#     def __eq__(self, other) -> bool:
#         return isinstance(other, Right) and self._value == other._value
# 
#     def __str__(self) -> str:
#         return "Right %s" % self._value
# 
# class Left(Either[TSource, TError]):
# 
#     """Represents a computation that has failed."""
# 
#     def __init__(self, error: TError) -> None:
#         self._error = error
# 
#     @classmethod
#     def pure(cls, value: Callable[[TSource], TResult]) -> Either[Callable[[TSource], TResult], TError]:
#         return Right(value)
# 
#     def apply(self, something: Either) -> Either:
#         return Left(self._error)
# 
#     def map(self, mapper: Callable[[TSource], TResult]) -> Either[TResult, TError]:
#         return Left(self._error)
# 
#     @classmethod
#     def unit(cls, value: TSource):
#         return Right(value)
# 
#     def bind(self, func: Callable[[TSource], Either[TResult, TError]]) -> Either[TResult, TError]:
#         return Left(self._error)
# 
#     def __eq__(self, other) -> bool:
#         return isinstance(other, Left) and self._error == other._error
# 
#     def __str__(self) -> str:
#         return "Left: %s" % self._error


import unittest
from oslash.either import Right, Left

        self.assertEqual(Right(3).map(lambda x: x), Right(3))

    def test_either_right_functor_law2(self) -> None:
        """fmap (f . g) x = fmap f (fmap g x)"""
        def f(x: int) -> int:
            return x + 10

        def g(x: int) -> int:
            return x * 10

        self.assertEqual(
            Right(42).map(f).map(g),
            Right(42).map(lambda x: g(f(x)))
        )

    def test_either_left_functor_law1(self) -> None:
        """fmap id = id"""

        self.assertEqual(Left(3).map(lambda x: x), Left(3))

    def test_either_left_functor_law2(self) -> None:
        """fmap (f . g) x = fmap f (fmap g x)"""
        def f(x):
            return x + 10

        def g(x):
            return x * 10

        self.assertEqual(

# Path: oslash/either.py
# class Right(Either[TSource, TError]):
# 
#     """Represents a successful computation."""
# 
#     def __init__(self, value: TSource) -> None:
#         self._value = value
# 
#     # Functor Section
#     # ===============
# 
#     def map(self, mapper: Callable[[TSource], TResult]) -> Either[TResult, TError]:
#         result = mapper(self._value)
#         return Right(result)
# 
#     # Applicative Section
#     # ===================
# 
#     @classmethod
#     def pure(cls, value: Callable[[TSource], TResult]) -> "Right[Callable[[TSource], TResult], TError]":
#         return Right(value)
# 
#     def apply(
#         self: "Right[Callable[[TSource], TResult], TError]", something: "Either[TSource, TError]"
#     ) -> "Either[TResult, TError]":
#         def mapper(other_value):
#             try:
#                 return self._value(other_value)
#             except TypeError:
#                 return partial(self._value, other_value)
# 
#         return something.map(mapper)
# 
#     # Monad Section
#     # =============
# 
#     @classmethod
#     def unit(cls, value: TSource) -> "Right[TSource, TError]":
#         return Right(value)
# 
#     def bind(self, func: Callable[[TSource], Either[TResult, TError]]) -> Either[TResult, TError]:
#         return func(self._value)
# 
#     # Operator Overloads
#     # ==================
# 
#     def __eq__(self, other) -> bool:
#         return isinstance(other, Right) and self._value == other._value
# 
#     def __str__(self) -> str:
#         return "Right %s" % self._value
# 
# class Left(Either[TSource, TError]):
# 
#     """Represents a computation that has failed."""
# 
#     def __init__(self, error: TError) -> None:
#         self._error = error
# 
#     @classmethod
#     def pure(cls, value: Callable[[TSource], TResult]) -> Either[Callable[[TSource], TResult], TError]:
#         return Right(value)
# 
#     def apply(self, something: Either) -> Either:
#         return Left(self._error)
# 
#     def map(self, mapper: Callable[[TSource], TResult]) -> Either[TResult, TError]:
#         return Left(self._error)
# 
#     @classmethod
#     def unit(cls, value: TSource):
#         return Right(value)
# 
#     def bind(self, func: Callable[[TSource], Either[TResult, TError]]) -> Either[TResult, TError]:
#         return Left(self._error)
# 
#     def __eq__(self, other) -> bool:
#         return isinstance(other, Left) and self._error == other._error
# 
#     def __str__(self) -> str:
#         return "Left: %s" % self._error


# Path: tests/test_either.py
import unittest
from oslash.either import Right, Left


        self.assertEqual(Right(3).map(lambda x: x), Right(3))

    def test_either_right_functor_law2(self) -> None:
        """fmap (f . g) x = fmap f (fmap g x)"""
        def f(x: int) -> int:
            return x + 10

        def g(x: int) -> int:
            return x * 10

        self.assertEqual(
            Right(42).map(f).map(g),
            Right(42).map(lambda x: g(f(x)))
        )

    def test_either_left_functor_law1(self) -> None:
        """fmap id = id"""

        self.assertEqual(Left(3).map(lambda x: x), Left(3))

    def test_either_left_functor_law2(self) -> None:
        """fmap (f . g) x = fmap f (fmap g x)"""
        def f(x):
            return x + 10

        def g(x):
            return x * 10

        self.assertEqual(

            Left(42).map(f).map(g),