Calls a wrapped function in a container on this container. .. code:: python >>> from returns.io import IO >>> assert IO('a').apply(IO(lambda inner: inner + 'b')) == IO('ab') Or more complex example that shows how we can work with regular functi
(
self,
container: Kind1['IO', Callable[[_ValueType_co], _NewValueType]],
)
| 100 | return IO(function(self._inner_value)) |
| 101 | |
| 102 | def apply( |
| 103 | self, |
| 104 | container: Kind1['IO', Callable[[_ValueType_co], _NewValueType]], |
| 105 | ) -> 'IO[_NewValueType]': |
| 106 | """ |
| 107 | Calls a wrapped function in a container on this container. |
| 108 | |
| 109 | .. code:: python |
| 110 | |
| 111 | >>> from returns.io import IO |
| 112 | >>> assert IO('a').apply(IO(lambda inner: inner + 'b')) == IO('ab') |
| 113 | |
| 114 | Or more complex example that shows how we can work |
| 115 | with regular functions and multiple ``IO`` arguments: |
| 116 | |
| 117 | .. code:: python |
| 118 | |
| 119 | >>> from returns.curry import curry |
| 120 | |
| 121 | >>> @curry |
| 122 | ... def appliable(first: str, second: str) -> str: |
| 123 | ... return first + second |
| 124 | |
| 125 | >>> assert IO('b').apply(IO('a').apply(IO(appliable))) == IO('ab') |
| 126 | |
| 127 | """ |
| 128 | return self.map(dekind(container)._inner_value) # noqa: SLF001 |
| 129 | |
| 130 | def bind( |
| 131 | self, |
no test coverage detected