MCPcopy
hub / github.com/dry-python/returns / apply

Method apply

returns/future.py:200–222  ·  view source on GitHub ↗

Calls a wrapped function in a container on this container. .. code:: python >>> import anyio >>> from returns.future import Future >>> def transform(arg: int) -> str: ... return str(arg) + 'b' >>> assert anyio.run(

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

Source from the content-addressed store, hash-verified

198 return Future(_future.async_map(function, self._inner_value))
199
200 def apply(
201 self,
202 container: Kind1['Future', Callable[[_ValueType_co], _NewValueType]],
203 ) -> 'Future[_NewValueType]':
204 """
205 Calls a wrapped function in a container on this container.
206
207 .. code:: python
208
209 >>> import anyio
210 >>> from returns.future import Future
211
212 >>> def transform(arg: int) -> str:
213 ... return str(arg) + 'b'
214
215 >>> assert anyio.run(
216 ... Future.from_value(1).apply(
217 ... Future.from_value(transform),
218 ... ).awaitable,
219 ... ) == IO('1b')
220
221 """
222 return Future(_future.async_apply(dekind(container), self._inner_value))
223
224 def bind(
225 self,

Callers

nothing calls this directly

Calls 2

dekindFunction · 0.90
FutureClass · 0.85

Tested by

no test coverage detected