Created
September 21, 2016 15:39
-
-
Save chris-martin/affb7df76120f2ace2f2d0adcda1c4eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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