overlaps for Data.Vector.Mutable behaves oddly for empty vectors
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start with the basicOverlaps implementation for Data.Vector.Mutable shown in the issue. First establish and document the intended overlap semantics for empty vectors, including shared offsets and offsets inside non-empty vectors. Then align the implementation with that specification and add coverage for the discussed cases.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Haskell
- Stars
- 401
- Forks
- 145
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from haskell/vector
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Similar issues
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
enhancement tricorder
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
zip-archive-0.5 Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
commercialhaskell/stackage#8124 · 1 comment ·
-
chore
Difficulty 1/5 Under an hour Newbie friendliness 91/100
alunduil/alunduil-chezmoi#792 ·