19. A type class - Functor
trait Functor[F[_]] {
def map[A, B](fa: F[A], fab: A => B): F[B]
}
20. A type class - Functor
implicit val cFunctor = new Functor[Container] {
def map[A, B](fa: Container[A], fab: A => B): Container[B] =
Container(fab(fa.value))
}
35. Back to our functors !
Morphisms of S (Scal) Morphisms of S’ (Scal too)
A → A (identity) Option[A] → Option[A]
A → B Option[A] → Option[B]
Int → String Option[Int] → Option[String]