dry-python / dry-python/returns
Add `Identity` monad
未关闭
enhancement
- 主要语言
- Python
- 星标
- 4.4k
- 派生
- 155
- 平均合并
- 2 小时 27 分钟
- 30 天内合并 PR
- 22
描述
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
贡献指南
评估
这个 Issue 还没有评估数据。