Applies function to the inner value. Applies 'function' to the contents of the IO instance and returns a new ``Future`` object containing the result. 'function' should accept a single "normal" (non-container) argument and return a non-container result.
(
self,
function: Callable[[_ValueType_co], _NewValueType],
)
| 170 | return IO(await self._inner_value) |
| 171 | |
| 172 | def map( |
| 173 | self, |
| 174 | function: Callable[[_ValueType_co], _NewValueType], |
| 175 | ) -> 'Future[_NewValueType]': |
| 176 | """ |
| 177 | Applies function to the inner value. |
| 178 | |
| 179 | Applies 'function' to the contents of the IO instance |
| 180 | and returns a new ``Future`` object containing the result. |
| 181 | 'function' should accept a single "normal" (non-container) argument |
| 182 | and return a non-container result. |
| 183 | |
| 184 | .. code:: python |
| 185 | |
| 186 | >>> import anyio |
| 187 | >>> from returns.future import Future |
| 188 | >>> from returns.io import IO |
| 189 | |
| 190 | >>> def mappable(x: int) -> int: |
| 191 | ... return x + 1 |
| 192 | |
| 193 | >>> assert anyio.run( |
| 194 | ... Future.from_value(1).map(mappable).awaitable, |
| 195 | ... ) == IO(2) |
| 196 | |
| 197 | """ |
| 198 | return Future(_future.async_map(function, self._inner_value)) |
| 199 | |
| 200 | def apply( |
| 201 | self, |