cats icon indicating copy to clipboard operation
cats copied to clipboard

RFC: Clean up NonEmptyMap interface

Open nigredo-tori opened this issue 5 years ago • 3 comments

NonEmptyMap is a bit annoying to use due to some inconsistencies:

  • Although it has a .keys method like Map does, it doesn't have a corresponding .values method. There's something similar possible with .toNonEmptyList (from NonEmptyTraverse), but that's not very discoverable. I suggest we add def values: NonEmptyList[A] = this.toNonEmptyList.
  • It has a .toNel method that produces a NEL of pairs. This is inconsistent with .toList and (which is especially silly) with .toNonEmptyList. I suggest we rename toNel to pairs or something like that.

nigredo-tori avatar Dec 11 '19 08:12 nigredo-tori

Strong :+1: from me. The NonEmptyX APIs are just generally an inconsistent mess and will need a major overhaul for 3.0. I've been avoiding this for the most part until then, but if someone wants to try to do some binary-compatible clean-up sooner I'm all for it.

travisbrown avatar Dec 11 '19 08:12 travisbrown

If we are going to overhaul NEx in 3.0, I would like to bring back my original opinion back when they were organically introduced to cats: cats shouldn't be burdened with a collection library. I propose we consider moving them out in 3.0, keeping one for cats core's own use.

kailuowang avatar Dec 11 '19 12:12 kailuowang

@kailuowang Agreed. There will be some work involved in extricating Reducible and some of the other cata.data stuff, but I think it'd be worth it.

travisbrown avatar Dec 11 '19 12:12 travisbrown