Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Feature request: `traverseKeys` and `traverseKeysWith`

Aperta
#771 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
haskell
Ambito
data

Direzione di ricerca

Start by reading the existing mapKeys, traverse, assocs, fromList, and fromListWith entry points in the containers implementation. Compare the proposed traverseKeys and traverseKeysWith behavior with those APIs, then verify duplicate-key handling and complexity before adding tests that establish the requested types and results.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

feature-request IntMap Map

Currently there are functions

mapKeys :: (Ord k) => (j -> k) -> Map j a -> Map k a
traverse :: (Applicative f) => (a -> f b) -> Map k a -> f (Map k b)

but nothing of the type (Applicative f, Ord k) => (j -> f k) -> Map j a -> f (Map k a).

A sample implementation:

traverseKeys :: (Applicative f, Ord k) => (j -> f k) -> Map j a -> f (Map k a)
traverseKeys f = fmap fromList . traverse (\(j, a) -> (,a) <$> f j) . assocs

traverseKeysWith :: (Applicative f, Ord k) => (a -> a -> a) -> (j -> f k) -> Map j a -> f (Map k a)
traverseKeysWith c f = fmap (fromListWith c) . traverse (\(j, a) -> (,a) <$> f j) . assocs

which is O(n log n), if I'm not mistaken; though I haven't looked through the internals of the implementation to dig for further optimizations.

Lingua principale
Haskell
Stelle
355
Fork
194
Merge medio
3g 4h
PR unite (30g)
7

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di haskell/containers

Tutte le issue di haskell/containers

Issue simili

Altre issue su Haskell

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.