scalascalazscala-cats

What does `=>` mean in scala generics?


Reading both the documentation for Scalaz and Cats, I notice that they frequently use => in their generic/polymorphic field. For example, from the scalaz page on applicatives, it has the following definition for ap:

override def ap[A, B](fa: ZipList[A])(f: ZipList[A => B]): ZipList[B] =
    ZipList((fa.value zip f.value).map(t => t._2(t._1)))

Now, I think understand the use of => inside the map, here its acting as part of a lambda, and I can guess that the => on the first line is adding the requirement that A and B be for a function. But I can't seem to find any documentation confirming this.

So, what is the purpose of => when used inside a generic/polymorphic field definition in Scala?


Solution

  • A => B is the same as Function1[A, B], that is the type of a function taking an A and returning a B.