Nested newtype wrapper vs Stream/StreamK Applicative and Monad instances

Aperta
#3,115 0 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
25/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
haskell
Ambito
backend

Direzione di ricerca

Read the Stream and StreamK newtype wrappers and their Applicative, Monad, Semigroup, and MonadPlus instances in streamly-core. Compare the performance implications of bind association and append, and assess whether adding these instances or using explicit concatFor operations best addresses the concerns in the issue; the issue does not name files or tests, so first locate the relevant definitions.

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

Descrizione

aspect:api

Do we want MonadState, MonadReader etc instances in future for this type? If so we will need to depend on mtl - streamly-core currently does not depend on mtl. Or we will have to move these types to streamly instead of streamly-core.

Another option is - instead of using newtype wrappers we can merge these instances with the Stream and StreamK types. We can use the concatFor (bind) operations directly instead of Monad instance, but a Monad instance could be useful where it is used implicitly - e.g. MonadComprehensions. We did not add a Monad instance earlier to avoid the misuse of the monad instance. What are the potential misuses?

  • We must not have Semigroup and MonadPlus instances for Stream type so it cannot be appended, append has quadratic complexity for Stream, though we can have it for StreamK which has a linear append.
  • Left associating the binds in a chain could hurt performance - they should be explicitly right associated
  • Applicative should be preferred as it would be much faster - maybe we can just provide an Applicative and leave the monad type composition to explicit concatFor (bind) operations.
Lingua principale
Haskell
Stelle
926
Fork
71
Merge medio
6h 49m
PR unite (30g)
3

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 composewell/streamly

Tutte le issue di composewell/streamly

Issue simili

Altre issue su Haskell

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.