Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

partitionE for Nel #1743

Closed
fommil opened this issue Jun 26, 2017 · 3 comments
Closed

partitionE for Nel #1743

fommil opened this issue Jun 26, 2017 · 3 comments

Comments

@fommil
Copy link

fommil commented Jun 26, 2017

any interest in this?

  // a partitionE for Nel
  implicit class PartitionE[E](trav: NonEmptyList[E]) {
    @SuppressWarnings(Array("org.wartremover.warts.Throw"))
    def partitionE[A, B](
        f: E => Either[A, B]
      ): (Ior[NonEmptyList[A], NonEmptyList[B]]) = {
      val (lefts, rights) = trav.toList.map(f).partition(_.isLeft)
      Ior
        .fromOptions(
          Nel(lefts.collect { case Left(left) => left }),
          Nel(rights.collect { case Right(right) => right })
        )
        .getOrElse {
          throw new IllegalStateException("impossible")
        }
    }
  }
@edmundnoble
Copy link
Contributor

Love it, 👍

@fommil fommil closed this as completed Aug 25, 2017
@LukaJCB
Copy link
Member

LukaJCB commented Aug 26, 2017

Why was this closed? I still think this is a valuable addition 🤔

@fommil
Copy link
Author

fommil commented Aug 26, 2017

I don't have plans to contribute it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants