In Java, we can abstract over type variables. After all, we don't write a length
function for
List<String>, List<Integer>, List<Person>
and so on.
With Scala, we can abstract over type constructors.
trait Mappable[F[_]] { def map[A, B](fa: F[A], f: A => B): F[B] }
Some type constructors that are Mappable
:
List
Option
Either[X, _]
Either[_, Y]
Function[X, _]