MCPcopy Index your code
hub / github.com/dry-python/returns / bind

Method bind

returns/future.py:224–248  ·  view source on GitHub ↗

Applies 'function' to the result of a previous calculation. 'function' should accept a single "normal" (non-container) argument and return ``Future`` type object. .. code:: python >>> import anyio >>> from returns.future import Future

(
        self,
        function: Callable[[_ValueType_co], Kind1['Future', _NewValueType]],
    )

Source from the content-addressed store, hash-verified

222 return Future(_future.async_apply(dekind(container), self._inner_value))
223
224 def bind(
225 self,
226 function: Callable[[_ValueType_co], Kind1['Future', _NewValueType]],
227 ) -> 'Future[_NewValueType]':
228 """
229 Applies 'function' to the result of a previous calculation.
230
231 'function' should accept a single "normal" (non-container) argument
232 and return ``Future`` type object.
233
234 .. code:: python
235
236 >>> import anyio
237 >>> from returns.future import Future
238 >>> from returns.io import IO
239
240 >>> def bindable(x: int) -> Future[int]:
241 ... return Future.from_value(x + 1)
242
243 >>> assert anyio.run(
244 ... Future.from_value(1).bind(bindable).awaitable,
245 ... ) == IO(2)
246
247 """
248 return Future(_future.async_bind(function, self._inner_value))
249
250 #: Alias for `bind` method. Part of the `FutureBasedN` interface.
251 bind_future = bind

Callers

nothing calls this directly

Calls 1

FutureClass · 0.85

Tested by

no test coverage detected