Add Seq syntax parallel to ListOps
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 5.5k
- Forks
- 1.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 5
Description
In ListOps we have a few helper methods for producing NonEmptyLists via grouping, emptiness check, etc.. We can do the same thing with Seq and NonEmptySeq.
My specific use case (which I have hit a few times by this point) is that I have a Seq[Value], and I want to group it into a Map[Key, NonEmptySeq[Value]]. At the moment there are two ways to do this:
val values: Seq[Value] = ???
def f(v: Value): Key = ???
// This switches to `List`s which can be inefficient. Also, this is noisy, and it has an "unsafe" call.
values.toList.groupByNel(f).mapValues(nel => NonEmptySeq.fromSeqUnsafe(nel.toList))
// This is still noisy
NonEmptySeq.fromSeq(values).map(_.groupByNem(f).toMap)(Map.empty)
This might be a subset of #4070, but that one is huge and stale. I'd rather have a separate issue for this specific pain point.
Contributor guide
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.
Research direction
Start by reading the existing ListOps helpers and the Seq and NonEmptySeq APIs, then compare the requested scope with issue #4070. The work is done when Seq has equivalent grouping and emptiness-related helpers for producing NonEmptySeq values, with tests covering the stated Seq[Value] grouping use case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100