Slide 24
Slide 24 text
def traverse[F[_]: Applicative, A, B]
(as: List[A])(f: A => F[B]): F[List[B]]
def reciprocal(i: Int): Either[String, Double] =
if (i == 0) Left("reciprocal of 0")
else Right(1.0 / i)
traverse(List(1, 2, 3))(reciprocal)
Puzzle solving
traverse[Either[String, ?], Int, Double]
traverse[Either[?, Double], Int, String]
'?' syntax is via the kind-projector compiler plugin: https://github.com/non/kind-projector