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

Support Literal types #274

Open
sobolevn opened this issue Jul 13, 2021 · 0 comments
Open

Support Literal types #274

sobolevn opened this issue Jul 13, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@sobolevn
Copy link
Member

After we have delegate in-place we can use Literal types.

But, now they are not supported.
Ideally, something like this should work:

from classes import typeclass, AssociatedType, Supports
from typing_extensions import Literal

class SomeDelegate(object):
    ...  # TODO: write proper `__instancecheck__`

class A(AssociatedType):
    ...

@typeclass(A)
def some(instance) -> int:
    ...

@some.instance(Literal[1], delegate=SomeDelegate)
def _some_tuple(instance: Literal[1]) -> int:
    return instance

def test(i: Supports[A]):
    return some(i)

some(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

1 participant