dry-python / dry-python/classes

Typeclasses with several methods

Aperta
#83 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
enhancement help wanted
Lingua principale
Python
Stelle
730
Fork
30
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.