dry-python / dry-python/classes
Typeclasses with several methods
未關閉
enhancement
help wanted
- 主要語言
- Python
- 星號
- 730
- 分支
- 30
- PR 合併指標
- 30 天內沒有已合併 PR
描述
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.
貢獻指南
評估
這個 Issue 還沒有評估資料。