2. ...you don't need to know what is it in case of this topic.
MONADS
8MINUTESOF MONADTRANSFORMERS
Future("1")
.map(_ + "0")
.map(_.toInt)
// result: 10
List("1", "2", "3", "4")
.map(_.toInt)
.map(_ * 2)
// result: [2, 4, 6, 8]
3. ...you don't need to know what is it in case of this topic.
MONADS
8MINUTESOF MONADTRANSFORMERS
Future("1")
.map(_ + "0")
.map(_.toInt)
// result: 10
List("1", "2", "3", "4")
.map(_.toInt)
.map(_ * 2)
// result: 2, 4, 6, 8
4. ...you don't need to know what is it in case of this
topic.
MONAD
8MINUTESOF MONADTRANSFORMERS
Future(List("1", "2", "3"))
.map(???)
5. ...way to use nested monads.
MONAD T
8MINUTESOF MONADTRANSFORMERS
Future(List("1", "2", "3"))
.map(_.map(doSmth))
6. ...way to use nested monads.
MONAD T
8MINUTESOF MONADTRANSFORMERS
implicit class FutureListMonadT[A](a: Future[List[A]]) {
def mapT[B](f: A => B): Future[List[B]] =
a.map(_.map(f))
}
Future(List("1", "2", "3"))
.mapT(doSmth)