emilypi / emilypi/nonempty-vector
Add grouping and sorting utilities to NonEmptyVector (parity with NonEmptyList)
- Dominant language
- Haskell
- Stars
- 26
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
## Description
I am refactoring some of my code to use `nonempty-vector` instead of `NonEmpty` lists and noticed that `NonEmptyVector` currently lacks some of the convenient utility functions available on `NonEmptyList`, such as `groupBy`, `groupAllWith`, and sorting helpers like `sort` or `sortOn`.
This makes migration from `NonEmptyList` to `NonEmptyVector` less ergonomic, since code that previously relied on these functions must now be rewritten manually using conversions or workarounds.
If others are interested in this feature as well, I would be happy to submit a PR.
## Example
```haskell
xs :: NonEmptyVector Int
xs = unsafeFromList (3 :| [1, 2, 1])
```
-- desired
```haskell
NEV.groupBy myPredicate xs
sortOn id xs
```
-- currently required
```haskell
NEV.unsafeVector $ groupBy myPredicate (NEV.toVector xs)
NEV.unsafeVector $ sortOn id (NEV.toVector xs)
```
## Proposal
Add the following (or equivalent) functions to `NonEmptyVector`:
- `groupBy`
- `groupAllWith`
- `sort`
- `sortOn`
to achieve feature parity with `NonEmptyList`.
## Motivation
- Ease migration from `NonEmptyList`
- Improve consistency between `NonEmpty*` data types
- Avoid unnecessary conversions or loss of non-empty guarantees
## Environment
- Library version: vector-nonempty 0.2.4
- GHC version: 9.6.6
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.