dry-python / dry-python/classes

Typeclasses with several methods

Abierto
#83 2 comentarios 0 reacciones 0 asignados Ver en GitHub
enhancement help wanted
Lenguaje dominante
Python
Estrellas
730
Forks
30
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.