Beispiel #1
0
    def test_right_bind_calls_with_value_other_type(self) -> None:
        def f(x: _T) -> Either[_U, str]:
            return Right('yay')

        assert Right(1).bind(f) == Right('yay')
        assert (Right(1) >> f) == Right('yay')
Beispiel #2
0
 def f(x: _T) -> Either[_U, str]:
     return Right('yay')
Beispiel #3
0
 def inc(x: int) -> Either[_T, int]:
     return Right(x + 1)
Beispiel #4
0
    def test_right_bind_calls_with_value(self) -> None:
        def inc(x: int) -> Either[_T, int]:
            return Right(x + 1)

        assert Right(1).bind(inc) == Right(2)
        assert (Right(1) >> inc) == Right(2)
Beispiel #5
0
 def test_right(self) -> None:
     assert Right(42).__repr__() == 'Right(42)'
Beispiel #6
0
 def test_right_fmap_calls_with_value_other_type(self) -> None:
     assert Right(1).fmap(lambda x: 'yay') == Right('yay')
Beispiel #7
0
 def test_right_fmap_calls_with_value(self) -> None:
     assert Right(1).fmap(lambda x: x + 1) == Right(2)