Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding to_iterable converter #391

Open
sobolevn opened this issue May 28, 2020 · 6 comments
Open

Consider adding to_iterable converter #391

sobolevn opened this issue May 28, 2020 · 6 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@sobolevn
Copy link
Member

After #244 we now have .from_iterable constructor on every container.

We should also add to_iterable(container: Container[Sequence[T]]) -> Iterable[Container[T]]: (where Container is just an alias, we should support types for all existing containers).
So, this will allow us to construct and deconstruct values easily.

@sobolevn sobolevn added enhancement New feature or request help wanted Extra attention is needed labels May 28, 2020
@sobolevn sobolevn added this to the 0.14 milestone May 28, 2020
@sobolevn sobolevn changed the title Consider adding to_iterable converted Consider adding to_iterable converter May 28, 2020
@sobolevn
Copy link
Member Author

sobolevn commented Jun 1, 2020

I am really tired for now. Let's move it to the next release.

@sobolevn sobolevn removed this from the 0.14 milestone Jun 1, 2020
@thepabloaguilar thepabloaguilar self-assigned this Sep 3, 2020
@thepabloaguilar
Copy link
Member

We have a problem with HKT here, it can't convert Sequence[Kind1[_ContainerKind, _FirstType]] to Sequence[Container[_FirstType]]!

@kinded
def to_iterable(
    container: KindN[
        _ContainerKind, Sequence[_FirstType], _SecondType, _ThirdType
    ]
) -> Sequence[KindN[_ContainerKind, _FirstType, _SecondType, _ThirdType]]:
    ...

mypy output:

returns/converters.py:97: error: Value of type variable "_FunctionType" of "kinded" cannot be "Callable[[KindN[_ContainerKind, Sequence[_FirstType], _SecondType, _ThirdType]], Sequence[KindN[_ContainerKind, _FirstType, _SecondType, _ThirdType]]]"

Do you want to open an issue for this?

@sobolevn
Copy link
Member Author

sobolevn commented Sep 5, 2020

Ok, I see. @kinded forces us to have KindN as a return type. I think, that this is a correct behaviour. Not a bug.

Any ideas on how to support it?

@thepabloaguilar
Copy link
Member

I don't have any ideas 😞

@sobolevn
Copy link
Member Author

Ok, we should change how @kinded works in the future.
Because we can and will have cases when we need wrapped expressions like List[KindN[...].
Today I have tried to write Maybe[KindN[...]], but I was not able to do that. That's sad.

But, to fully support this, we need python/mypy#9001 to be released.

@thepabloaguilar
Copy link
Member

I'm excited waiting for the next mypy release, should be fixed at least three issues here hahaha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Development

No branches or pull requests

2 participants