Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

8 minutes of monad transformers

92 views

Published on

Lightning talk about monad transformers.

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

8 minutes of monad transformers

  1. 1. 8 MINUTES OF MONAD TRANSFORMERS THINGS THAT YOU ARE AFRAID TO ASK HASKELL DEVELOPERS
  2. 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. 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. 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. 5. ...way to use nested monads. MONAD T 8MINUTESOF MONADTRANSFORMERS Future(List("1", "2", "3"))        .map(_.map(doSmth))
  6. 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)
  7. 7. THANKS! TIME TO ARGUE

×