|
24 | 24 |
|
25 | 25 | The main idea behind a container is that it wraps some internal state.
|
26 | 26 | That's what
|
27 |
| -:py:attr:`._inner_value <returns.primitives.container.Container._inner_value>` |
| 27 | +:attr:`._inner_value <returns.primitives.container.Container._inner_value>` |
28 | 28 | is used for.
|
29 | 29 |
|
30 | 30 | And we have several functions
|
@@ -153,27 +153,27 @@ Composition
|
153 | 153 | -----------
|
154 | 154 |
|
155 | 155 | You can and should compose different containers together.
|
156 |
| -Here's the full table of compositions that make sense: |
157 |
| - |
158 |
| -Ok |
159 |
| -~~ |
160 |
| - |
161 |
| -- ``IO[Result[A, B]]`` ✅ |
162 |
| -- ``IO[Maybe[A]]`` ✅ |
| 156 | +Here's a table of some compositions that do not make sense: |
163 | 157 |
|
164 | 158 | Needs transformation
|
165 | 159 | ~~~~~~~~~~~~~~~~~~~~
|
166 | 160 |
|
| 161 | +- ``IO[Result[A, B]]`` 🤔, |
| 162 | + use :meth:`returns.io.IOResult.from_typecast` and ``IOResult`` |
| 163 | +- ``IO[Maybe[A]]`` 🤔, |
| 164 | + use :func:`maybe_to_result <returns.converters.maybe_to_result>` |
| 165 | + and then :meth:`returns.io.IOResult.from_typecast` |
| 166 | + to convert it to ``IOResult`` |
167 | 167 | - ``IO[IO[A]]`` 🤔, use :func:`flatten <returns.converters.flatten>`
|
168 | 168 | - ``Maybe[Maybe[A]]`` 🤔, use :func:`flatten <returns.converters.flatten>`
|
169 | 169 | - ``Result[Result[A, B], C]`` 🤔,
|
170 |
| - use :func:`flatten <returns.converters.flatten>` |
| 170 | + use :func:`flatten <returns.converters.flatten>` |
171 | 171 | - ``Result[Maybe[A], B]`` 🤔,
|
172 |
| - use :func:`maybe_to_result <returns.converters.maybe_to_result>` |
173 |
| - and then :func:`flatten <returns.converters.flatten>` |
| 172 | + use :func:`maybe_to_result <returns.converters.maybe_to_result>` |
| 173 | + and then :func:`flatten <returns.converters.flatten>` |
174 | 174 | - ``Maybe[Result[A, B]]`` 🤔,
|
175 |
| - use :func:`result_to_maybe <returns.converters.result_to_maybe>` |
176 |
| - and then :func:`flatten <returns.converters.flatten>` |
| 175 | + use :func:`result_to_maybe <returns.converters.result_to_maybe>` |
| 176 | + and then :func:`flatten <returns.converters.flatten>` |
177 | 177 |
|
178 | 178 | Nope
|
179 | 179 | ~~~~
|
|
183 | 183 | - ``Result[A, Maybe[B]]`` 🚫
|
184 | 184 | - ``Result[A, Result[B, C]]`` 🚫
|
185 | 185 | - ``Maybe[IO[A]]`` 🚫
|
| 186 | +- ``RequiresContext[IO[A], B]`` 🚫 |
186 | 187 |
|
187 | 188 | You can use :ref:`converters` to convert ``Maybe`` and ``Result`` containers.
|
188 | 189 | You can also use :func:`flatten <returns.converters.flatten>`
|
|
0 commit comments