Generic mapN and zipN

Aperta
#173 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
30/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma

Direzione di ricerca

Read the issue’s proposed map2–map10 and zip2–zip10 signatures, then inspect the existing zip implementation and the project’s typeclass conventions. Decide which abstraction can support the proposed generic operations and how Tuple and Tuple2 should differ; done means the API design and its supported types are agreed before implementation.

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

Descrizione

status: blocked

Proposing we add these mapN functions, and make them available to more than just List.

map2 :: forall a b c f. Functor f => (a -> b -> c) -> f a -> f b -> f c
map3 :: forall a b c d f. Functor f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
...
map10 ...

We can then use the mapN functions to create zipN functions:

-- This already exists, but it would be nice to offer a more generic version:
zip :: forall a b f. Functor f => f a -> f b -> Tuple a b
zip = map2 Tuple

-- Likely needed to fill the gap between the seemingly-identical
-- (but actually different) `Tuple` and nested `Tuple2`.
zip2 :: forall a b f. Functor f => f a -> f b -> f (Tuple2 a b)
zip2 = map2 Tuple2

zip3 :: forall a b c f. Functor f => f a -> f b -> f c -> f (Tuple3 a b c)
zip3 = map3 Tuple3
...
zip10 :: ...
zip10 = map10 Tuple10

We probably need a different typeclass than Functor though. What about Zippable?

A motivation for adding these functions is to get closer to Elm's usability in this area:
https://package.elm-lang.org/packages/elm/core/latest/List#map2

Lingua principale
PureScript
Stelle
61
Fork
50
Merge medio
2g 6h
PR unite (30g)
1

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

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 purescript/purescript-lists

Tutte le issue di purescript/purescript-lists

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.