Skip to content

Instantly share code, notes, and snippets.

@salanki
Forked from ceedubs/gist:8589661
Last active August 27, 2023 16:52
Show Gist options
  • Save salanki/8609177 to your computer and use it in GitHub Desktop.
Save salanki/8609177 to your computer and use it in GitHub Desktop.
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
@salanki
Copy link
Author

salanki commented Jan 25, 2014

for {
  thing1 <- Future.successful("Kebab").liftM[ErrorsOrT]
  thing2 <-  EitherT(Future.successful(1.right))
} yield thing1 + thing2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment