Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Feature request: Set.traverse

オープン
#779 コメント 11 件 リアクション 3 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
haskell
領域
data

調査の方向性

まず、既存の Set.map の動作と、提案されている toList/fromList および foldMap の実装を確認します。それらのセマンティクスと漸近的な性能特性やその他の性能特性を比較し、そのうえで、受け入れられる制約付きの Set.traverse の設計を決定します。プロジェクトが実装に合意し、対応する動作が検証されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

feature-request Set

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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

haskell/containers のほかの issue

haskell/containers の issue をすべて見る

似ている issue

Haskell の issue をもっと見る

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

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