cats icon indicating copy to clipboard operation
cats copied to clipboard

add EitherNev alias and syntax

Open eugkhp opened this issue 3 years ago • 8 comments

I'm using Vector a lot in my 2.13.7 codebase since it's one of the best collections right now and we either need to have those aliases in the business code or convert to List/Chanin in order to use cats' syntax. After asking if it exists somewhere @armanbilge said we can add it to cats.

eugkhp avatar Aug 24 '22 17:08 eugkhp

CI doesn't seem to be running 🤔

armanbilge avatar Aug 24 '22 18:08 armanbilge

Looks like CI finished 🙌

eugkhp avatar Aug 24 '22 18:08 eugkhp

Added both add IorNev and ValidatedNev

eugkhp avatar Aug 25 '22 19:08 eugkhp

actually... I wonder if we are moving in the wrong direction here.

Like, what if instead we did:

def toValidatedA[F[_]: Applicative](e: Either[A, B]): Validated[F[A], B] =
  e match {
    case Right(b) => Validated.valid(b)
    case Left(a) => Validated.invalid(Applicative[F].pure(a))
  }

then add a low priority typeclass instance for Applicative[Validated[F[A], *]] given a SemigroupK[F].

Then all these instances would be the same.

johnynek avatar Aug 26 '22 20:08 johnynek

Sure, writing that boilerplate was kinda annoying, especially trying to find all existing ones and make them consistent. I can prepare another MR or add to the existing one. What do you prefer?

eugkhp avatar Aug 26 '22 20:08 eugkhp

@key-eugene are you still interested to work on Oscar's proposal? Seems like an interesting idea, I guess a separate PR would make more sense.

armanbilge avatar Oct 12 '22 04:10 armanbilge

Yeah, I like that idea too. Seems similar to the discussion we have around generalization of group-alike methods in other PRs – instead of hardcoding output types we could try to elaborate on making them more generic.

satorg avatar Oct 12 '22 04:10 satorg

@armanbilge yep! Should I close this one or we can merge it and I will work from there?

eugkhp avatar Oct 14 '22 10:10 eugkhp

made another PR with proposed changes #4336

eugkhp avatar Nov 06 '22 12:11 eugkhp