Last active
August 29, 2015 14:14
-
-
Save gabro/5127337477a835d1a7e7 to your computer and use it in GitHub Desktop.
OptionT exercise
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 scala.concurrent.ExecutionContext.Implicits.global | |
def getInteger(x: Int): OptionT[Future, Int] = 42.point[Future].liftM[OptionT] | |
def computeList(n: Int): OptionT[Future, List[Int]] = (1 to n).toList.traverseU(getInteger) | |
//if you need a Future[OptionT[List[Int]]] just use run | |
computeList(3).run // Some(List(1, 2, 3)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment