Skip to content

Instantly share code, notes, and snippets.

@chris-martin
Created September 21, 2016 15:39
Show Gist options
  • Save chris-martin/affb7df76120f2ace2f2d0adcda1c4eb to your computer and use it in GitHub Desktop.
Save chris-martin/affb7df76120f2ace2f2d0adcda1c4eb to your computer and use it in GitHub Desktop.
import scalaz._, Scalaz._
def f[A, B](xs: List[Either[List[A], B]]): List[Either[A, B]] =
xs.flatMap(_.fold(_.map(Left(_)), b => List(Right(b))))
def g[A, B](xs: IList[IList[A] \/ B]): IList[A \/ B] =
xs.flatMap(_.bitraverse(identity, IList(_)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment