Skip to content

Instantly share code, notes, and snippets.

@vmarquez
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vmarquez/af95fa292e02f2e11594 to your computer and use it in GitHub Desktop.
Save vmarquez/af95fa292e02f2e11594 to your computer and use it in GitHub Desktop.
import scala.concurrent.Future
import scalaz._
import Scalaz._
import scala.concurrent.ExecutionContext.Implicits.global
val fa = OptionT( Future { 1.some } )//Returns an OptionT[Future,Int]
val fb = OptionT( Future { 2.some } )
//we don't need to nest for comprehensions since the OptionT unwraps the Option
// automatically in addition to whatever monad it's abstracting over
for {
a <- fa
b <- fb
} yield (a + b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment