Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Using mutable and immutable vectors together is painful

Open
#159 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
haskell
Domain
data

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.Generic and Data.Vector.Generic.Mutable in the same module means one must qualify all the slice and length ops, for example take and drop, 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 far
    • windows :: 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from haskell/vector

All issues in haskell/vector

Similar issues

More Haskell issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.