dry-python / dry-python/classes
Typeclasses with several methods
- Ngôn ngữ chính
- Python
- Star
- 730
- Fork
- 30
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
There's a common use-case when we need to create a type-class with several methods. Like:
```python
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:
```python
@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.
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.