Typeclasses with several methods
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
No files, tests, or entry points are named. Start by tracing how the current typeclass mechanism represents and binds implementations, then determine how a Python Protocol with several methods, including the classmethod, should be supported. Done means the proposed Functor shape works and its implementation binding is defined and covered by tests.
Written by the indexing model from the issue text.
Description
There's a common use-case when we need to create a type-class with several methods. Like:
class Functor(Protocol[T]):
def map(self, function: Callable[[T], Functor[V]]) -> Functor[V]:
...
@classmethod
def from_value(cls, inner_value: V) -> Functor[V]:
...
Currently, there's no way we can do that.
I propose something like this:
@typeclass
class Functor(Protocol[T]):
def map(self, function: Callable[[T], Functor[V]]) -> Functor[V]:
...
@classmethod
def from_value(cls, inner_value: V) -> Functor[V]:
...
I am not sure how to bound it to the actual implementation.
- Dominant language
- Python
- Stars
- 730
- Forks
- 30
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dry-python/classes
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
dry-python/classes#496 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
dry-python/classes#494 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 52/100
dry-python/classes#492 · 2 comments ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 35/100
dry-python/classes#481 · 5 comments · 4 reactions ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
dry-python/classes#386 ·
All issues in dry-python/classes
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
browser-use/browser-use#5905 ·
-
type: enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ynput/ayon-python-api#363 ·
-
bug needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
modelscope/FunASR#3728 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
open-compass/opencompass#2655 ·