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

Method apply

returns/io.py:102–128  ·  view source on GitHub ↗

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]],
    )

Source from the content-addressed store, hash-verified

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,

Callers 1

_concat_applicativeFunction · 0.45

Calls 2

mapMethod · 0.95
dekindFunction · 0.90

Tested by

no test coverage detected