Binds a function returning ``IO[a]`` container. .. code:: python >>> import anyio >>> from returns.io import IO, IOSuccess, IOFailure >>> from returns.future import FutureResult >>> def bind(inner_value: int) -> IO[float]: ...
(
self,
function: Callable[[_ValueType_co], IO[_NewValueType]],
)
| 965 | ) |
| 966 | |
| 967 | def bind_io( |
| 968 | self, |
| 969 | function: Callable[[_ValueType_co], IO[_NewValueType]], |
| 970 | ) -> 'FutureResult[_NewValueType, _ErrorType_co]': |
| 971 | """ |
| 972 | Binds a function returning ``IO[a]`` container. |
| 973 | |
| 974 | .. code:: python |
| 975 | |
| 976 | >>> import anyio |
| 977 | >>> from returns.io import IO, IOSuccess, IOFailure |
| 978 | >>> from returns.future import FutureResult |
| 979 | |
| 980 | >>> def bind(inner_value: int) -> IO[float]: |
| 981 | ... return IO(inner_value + 0.5) |
| 982 | |
| 983 | >>> assert anyio.run( |
| 984 | ... FutureResult.from_value(1).bind_io(bind).awaitable, |
| 985 | ... ) == IOSuccess(1.5) |
| 986 | >>> assert anyio.run( |
| 987 | ... FutureResult.from_failure(1).bind_io(bind).awaitable, |
| 988 | ... ) == IOFailure(1) |
| 989 | |
| 990 | """ |
| 991 | return FutureResult( |
| 992 | _future_result.async_bind_io( |
| 993 | function, |
| 994 | self._inner_value, |
| 995 | ) |
| 996 | ) |
| 997 | |
| 998 | def bind_future( |
| 999 | self, |
nothing calls this directly
no test coverage detected