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

Method bind

returns/io.py:130–148  ·  view source on GitHub ↗

Applies 'function' to the result of a previous calculation. 'function' should accept a single "normal" (non-container) argument and return ``IO`` type object. .. code:: python >>> def bindable(string: str) -> IO[str]: ... return IO(string

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

Source from the content-addressed store, hash-verified

128 return self.map(dekind(container)._inner_value) # noqa: SLF001
129
130 def bind(
131 self,
132 function: Callable[[_ValueType_co], Kind1['IO', _NewValueType]],
133 ) -> 'IO[_NewValueType]':
134 """
135 Applies 'function' to the result of a previous calculation.
136
137 'function' should accept a single "normal" (non-container) argument
138 and return ``IO`` type object.
139
140 .. code:: python
141
142 >>> def bindable(string: str) -> IO[str]:
143 ... return IO(string + 'b')
144
145 >>> assert IO('a').bind(bindable) == IO('ab')
146
147 """
148 return dekind(function(self._inner_value))
149
150 #: Alias for `bind` method. Part of the `IOLikeN` interface.
151 bind_io = bind

Callers 2

_intermediate_argspecFunction · 0.45
flattenFunction · 0.45

Calls 1

dekindFunction · 0.90

Tested by

no test coverage detected