Skip to content

Instantly share code, notes, and snippets.

@gigiigig
Created October 2, 2014 23:19
Show Gist options
  • Save gigiigig/9d5c17ba848414e4804f to your computer and use it in GitHub Desktop.
Save gigiigig/9d5c17ba848414e4804f to your computer and use it in GitHub Desktop.
2 level monad transformer
import scalaz._
import Scalaz._
object console extends App {
type ListTOption[A] = ListT[Option, A]
val v1: Option[List[\/[String, Int]]] = 1.right[String].point[List].point[Option]
val v2: Option[List[\/[String, Int]]] = 2.right[String].point[List].point[Option]
val t1 = EitherT[ListTOption, String, Int](ListT(v1))
val t2 = EitherT[ListTOption, String, Int](ListT(v2))
val rt = for {
v1 <- t1
v2 <- t2
} yield v1 + v2
val res = rt.run.run
println(s"res: ${res}")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment