How to simplify nested map calls?
Suppose I have a few nested functors, e.g. List[Option[Int]] and need to call the map of the most inner one. Now I am using nested maps : scala> val opts: List[Option[Int]] = List(Some(0), Some(1)) opts: List[Option[Int]] = List(Some(0), Some(1)) scala> opts.map(o => o.map(_ + 1)) res0: List[Option[Int]] = List(Some(1), Some(2)) What if I have 3 nesting levels, for instance ? Is there any simple alternative to nested maps ? Yes, this is possible with scalaz.Functor: scala> import scalaz.Functor import scalaz.Functor scala> import scalaz.std.list._ import scalaz.std.list._ scala> import scalaz