Traversable

trait Traversable[T[_]] {

  def traverse[A, B, F[_]: Applicative]
    (f: A => F[B])(ta: T[A])(implicit ft: Functor[T]): F[T[B]] =
      sequence(ft.map(ta)(f))

  def sequence[A, F[_]: Applicative]
    (x: T[F[A]])(implicit ft: Functor[T]): F[T[A]] =
      traverse[F[A], A, F](identity)(x)
}
object Traversable {

  def traverse[A, B, F[_]: Applicative, T[_]: Traversable: Functor]
    (f: A => F[B])(ta: T[A]): F[T[B]] =
      implicitly[Traversable[T]].traverse(f)(ta)

  def sequence[A, F[_]: Applicative, T[_]: Traversable: Functor]
    (x: T[F[A]]): F[T[A]] =
      implicitly[Traversable[T]].sequence(x)
}

Dependencies