Created
February 5, 2012 17:51
-
-
Save retronym/1746887 to your computer and use it in GitHub Desktop.
EitherT sequence
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
scala> import scalaz._, Scalaz._, effect._ | |
import scalaz._ | |
import Scalaz._ | |
import effect._ | |
scala> val listIoEither = List(EitherT[IO, Int, String](IO(Right("r")))) | |
listIoEither: List[scalaz.EitherT[scalaz.effect.IO,Int,String]] = List(scalaz.EitherTFunctions$$anon$20@49ab1824) | |
scala> val ioEitherList = listIoEither.sequenceU | |
ioEitherList: scalaz.EitherT[scalaz.effect.IO,Int,List[java.lang.String]] = scalaz.EitherTFunctions$$anon$20@5d38a346 | |
scala> ioEitherList.run.unsafePerformIO | |
res13: Either[Int,List[java.lang.String]] = Right(List(r)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This uses
Traverse[List]
andApplicative[[a]EitherT[IO, Int, a]]
.See:
https://github.com/scalaz/scalaz/blob/scalaz-seven/core/src/main/scala/scalaz/std/List.scala#L28
https://github.com/scalaz/scalaz/blob/scalaz-seven/core/src/main/scala/scalaz/EitherT.scala#L258
https://github.com/scalaz/scalaz/blob/scalaz-seven/core/src/main/scala/scalaz/EitherT.scala#L83