dry-python / dry-python/returns

Add `Identity` monad

オープン
#469 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る
enhancement
主要言語
Python
スター
4.4k
フォーク
155
平均マージ
2時間 27分
マージ済み PR(30日)
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 はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。