Feature request: Set.traverse
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
まず、既存の Set.map の動作と、提案されている toList/fromList および foldMap の実装を確認します。それらのセマンティクスと漸近的な性能特性やその他の性能特性を比較し、そのうえで、受け入れられる制約付きの Set.traverse の設計を決定します。プロジェクトが実装に合意し、対応する動作が検証されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
We can’t have a Traversable instance for Set, but there’s no reason we can’t have a constrained traverse just like we have Set.map even tho we can’t have Functor either. My initial attempt uses toList/fromList:
traverse :: (Ord b, Applicative f) => (a -> f b) -> Set a -> f (Set b)
traverse f = fmap fromList . Prelude.traverse f . toList
When I asked around on Twitter, @chris-martin came up with this variant:
traverse f = foldMap (fmap singleton . f)
which requires an extra Monoid (f a) constraint, but the latter was resolved by Liam Goodacre:
traverse f = getAp . foldMap (Ap . singleton . f)
I haven’t thought too hard about the asymptotics or other performance characteristics here, and there may well be better implementations possible, but it was certainly a fun thought experiment! What do folks think about adding a traverse for Set?
- 主要言語
- Haskell
- スター
- 355
- フォーク
- 194
- 平均マージ
- 3日 4時間
- マージ済み PR(30日)
- 7
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
haskell/containers のほかの issue
-
major-release strictness Tree
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
haskell/containers#1260 ·
メンテナーはふだん 2 日以内に返信
-
IntSet low-hanging-fruit performance
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
haskell/containers#1251 ·
メンテナーはふだん 2 日以内に返信
-
maintainability major-release
難易度 3/5 1〜2日 初心者へのやさしさ 70/100
haskell/containers#1250 ·
メンテナーはふだん 2 日以内に返信
-
performance Tree
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
haskell/containers#1247 ·
メンテナーはふだん 2 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 50/100
haskell/containers#1242 ·
メンテナーはふだん 2 日以内に返信
haskell/containers の issue をすべて見る
似ている issue
-
Preserve bind arrowオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
alunduil/siren-json.hs#233 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
alunduil/network-arbitrary#180 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
jgm/asciidoc-hs#14 ·