-
-
Save salanki/8609177 to your computer and use it in GitHub Desktop.
This file contains 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._ | |
import Scalaz._ | |
import scala.concurrent.Future | |
import scalaz.contrib.std.scalaFuture._ // typeclass instances for Scala Future | |
import scala.concurrent.ExecutionContext.Implicits.global // implicit execution context...you probably want a better one for real-world | |
type ErrorsOrT[M[+_], +A] = EitherT[M, NonEmptyList[String], A] // String could be your error type of choice | |
for { | |
thing1 <- EitherT(Future.successful(1.right)) | |
thing2 <- Future.successful(2).liftM[ErrorsOrT] | |
} yield { | |
thing1 + thing2 | |
} | |
res7: scalaz.EitherT[scala.concurrent.Future,scalaz.NonEmptyList[String],Int] = scalaz.EitherTFunctions$$anon$11@45d1a86c |
Author
salanki
commented
Jan 25, 2014
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment