typelevel / typelevel/cats

Remove OneAnd?

Open
#2,089 1 comment 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
5.5k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
5

Description

OneAnd doesn't seem very useful to me now that Cats has first-class NonemptyList and NonemptyVector types. It can be awkward to work with, especially if you don't have type aliases and "companion" object set up for the type that you are working with.

It keeps its head element separate like a cons-list, making it not very efficient to use with a vector-like structure, but it combines by delegating to an Alternative instance, which isn't efficient for list-like structures.

People might reach for OneAnd when they want a non-empty version of a structure that doesn't have first-class non-empty support in Cats. Some common types that they might reach for are non-empty sets and non-empty maps. However, the OneAnd model doesn't actually work for those (see #1909 for an example).

I'm not sure that OneAnd cuts it as an abstraction, and I don't know anyone who is actually using it. I vote for removing it. Is there anyone who uses it and/or has reason for it to stay?

Here is a related gitter discussion.

Contributor guide

Open the contributing guide

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.

Research direction

Start by reviewing the OneAnd implementation and its usages, then read the related discussion in issue #1909 and the linked Gitter conversation. The issue does not name specific files or tests; completion would require an agreed decision on whether OneAnd should be retained or removed and a defined migration scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.