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

overlaps for Data.Vector.Mutable behaves oddly for empty vectors

Aperta
#444 2 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
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
haskell
Ambito
data

Direzione di ricerca

Inizia con l’implementazione di basicOverlaps per Data.Vector.Mutable mostrata nell’issue. Stabilisci e documenta innanzitutto la semantica prevista delle sovrapposizioni per i vettori vuoti, inclusi gli offset condivisi e gli offset all’interno di vettori non vuoti. Poi allinea l’implementazione a quella specifica e aggiungi la copertura per i casi discussi.

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

Descrizione

The basicOverlaps implementation for Data.Vector.Mutable is:

basicOverlaps (MVector i m arr1) (MVector j n arr2)
    = sameMutableArray arr1 arr2
      && (between i j (j+n) || between j i (i+m))
    where
      between x y z = x >= y && x < z

This will return True for two vectors where two vectors share the same mutable array and offset, but one has a zero length and the other has a non-zero length. I cannot find a precise definition of what it means for possibly-empty vectors to overlap, so it's hard to say for sure this is wrong, but it certainly disagrees with my understanding of what overlaps ought to mean.

I suggest this implementation instead:

basicOverlaps (MVector i m arr1) (MVector j n arr2)
    = sameMutableArray arr1 arr2 && i < j + n && j < i + m

That will still report an overlap for an empty vector with an offset in the middle of a containing non-empty vector, though. It's even less clear what the right answer is there. So I guess what we really need is a precise specification first, and then we can write an implementation that matches it.

Lingua principale
Haskell
Stelle
401
Fork
145
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

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/vector

Tutte le issue di haskell/vector

Issue simili

Altre issue su Haskell

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.