cats

Function: map[A, B](F[A])(A => B): F[B]
Monad[M[_]]

In [1]:
classpath.add(
  "org.typelevel" %% "cats-core" % "1.0.0-RC1"
);


4 new artifact(s)
4 new artifacts in macro
4 new artifacts in runtime
4 new artifacts in compile


In [6]:
import cats._, cats.instances.all._


import cats._, cats.instances.all._

In [7]:
val len: String => Int = _.length


len: String => Int = <function1>

In [8]:
Functor[List].map(List("scala", "cats")) (len)


res7: List[Int] = List(5, 4)

In [20]:
Functor[List].map(List[Int](1, 2, 3)) (_ / 2L)


res19: List[Long] = List(0L, 1L, 1L)

In [21]:
import cats.syntax.functor._


import cats.syntax.functor._

In [24]:
List("s", "cats").fproduct(len)


res23: List[(String, Int)] = List(("s", 1), ("cats", 4))

To be continued...