Skip to content

Instantly share code, notes, and snippets.

@gabro
Last active August 29, 2015 14:14
Show Gist options
  • Save gabro/5127337477a835d1a7e7 to your computer and use it in GitHub Desktop.
Save gabro/5127337477a835d1a7e7 to your computer and use it in GitHub Desktop.
OptionT exercise
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