Turns ``Kind1[IO, int]`` type into real ``IO[int]`` type. Should be used when you are left with accidental ``KindN`` instance when you really want to have the real type. Works with type arguments of any length. We use a custom ``mypy`` plugin to make sure types are correct.
(
kind: KindN[
_InstanceType_co, _TypeArgType1_co, _TypeArgType2_co, _TypeArgType3_co
],
)
| 155 | |
| 156 | |
| 157 | def dekind( |
| 158 | kind: KindN[ |
| 159 | _InstanceType_co, _TypeArgType1_co, _TypeArgType2_co, _TypeArgType3_co |
| 160 | ], |
| 161 | ) -> _InstanceType_co: |
| 162 | """ |
| 163 | Turns ``Kind1[IO, int]`` type into real ``IO[int]`` type. |
| 164 | |
| 165 | Should be used when you are left with accidental ``KindN`` instance |
| 166 | when you really want to have the real type. |
| 167 | |
| 168 | Works with type arguments of any length. |
| 169 | |
| 170 | We use a custom ``mypy`` plugin to make sure types are correct. |
| 171 | Otherwise, it is currently impossible to properly type this. |
| 172 | |
| 173 | In runtime it just returns the passed argument, nothing really happens: |
| 174 | |
| 175 | .. code:: python |
| 176 | |
| 177 | >>> from returns.io import IO |
| 178 | >>> from returns.primitives.hkt import Kind1 |
| 179 | |
| 180 | >>> container: Kind1[IO, int] = IO(1) |
| 181 | >>> assert dekind(container) is container |
| 182 | |
| 183 | However, please, do not use this function |
| 184 | unless you know exactly what you are doing and why do you need it. |
| 185 | """ |
| 186 | return kind # type: ignore |
| 187 | |
| 188 | |
| 189 | # Utils to define kinded functions |