dry-python / dry-python/returns

Add `Identity` monad

Abierto
#469 4 comentarios 0 reacciones 0 asignados Ver en GitHub
enhancement
Lenguaje dominante
Python
Estrellas
4.4k
Forks
155
Merge medio
2 h 27 min
PR fusionados (30 d)
22

Descripción

We need this to wrap regular values into a monad.
This might be required when you have a function like this:

```python
@kinded
def do_something(c: KindN[V, E, D], f: Callable[[V], N]) -> KindN[N, E, D]: ...
```

And you want to call it with just a plain value, like `1`.
Then, you wrap it into `Identity(1)` and pass into `do_something` with no problems.

`Maybe` does not fit for several reasons:
1. It does not support all possible methods, like `rescue`
2. It treats `None` differently, we should be able to wrap `Identity(None)` as is

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.