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
xs :: NonEmptyVector Int
xs = unsafeFromList (3 :| [1, 2, 1])
-- desired
NEV.groupBy myPredicate xs
sortOn id xs
-- currently required
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
Description
I am refactoring some of my code to use
nonempty-vectorinstead ofNonEmptylists and noticed thatNonEmptyVectorcurrently lacks some of the convenient utility functions available onNonEmptyList, such asgroupBy,groupAllWith, and sorting helpers likesortorsortOn.This makes migration from
NonEmptyListtoNonEmptyVectorless 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
-- desired
-- currently required
Proposal
Add the following (or equivalent) functions to
NonEmptyVector:groupBygroupAllWithsortsortOnto achieve feature parity with
NonEmptyList.Motivation
NonEmptyListNonEmpty*data typesEnvironment