Last active
August 29, 2015 14:05
-
-
Save vmarquez/af95fa292e02f2e11594 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 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