dry-python / dry-python/returns

Add `Identity` monad

Đang mở
#469 4 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
Python
Star
4.4k
Fork
155
Merge trung bình
2 giờ 27 phút
Pull request đã merge (30 ngày)
22

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.