Using mutable and immutable vectors together is painful
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start by reading Data.Vector.Generic and Data.Vector.Generic.Mutable, focusing on the overlapping slice and length operations and the proposed Slice class. Determine whether a shared API for immutable and mutable vectors fits the existing design, then implement and validate instances for the relevant Vector and MVector types if approved.
Written by the indexing model from the issue text.
Description
This is actually 2 closely-related issues:
- Importing both
Data.Vector.GenericandData.Vector.Generic.Mutablein the same module means one must qualify all the slice and length ops, for exampletakeanddrop, tho these are effectively the same operations on mutable and immutable vectors. - It is effectively impossible to write one term which works with both mutable and immutable vectors, for examples, all which i needed lately:
tails :: Vector v a => v a -> [v a]tailMay :: Vector v a => v a -> Maybe (v a)wrapSlice :: Vector v a => Int -> Int -> v a -> v a -- slice wrapping back to start if it goes too farwindows :: Vector v a => Int -> v a -> [v a] -- list of all subvectors of given length
It should be possible to use the same function to slice both mutable and immutable vectors. I propose this:
class Slice v where
length :: v a -> Int
unsafeSlice :: Int -> Int -> v a -> v a
and instances for all Vector and MVector types; i believe the other slicing functions can be defined in terms of these.
I can implement this, so let me know whether you approve.
- 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 ·