Skip to content

Commit

Permalink
Delegate to Traverse.sequence in Applicative.sequence
Browse files Browse the repository at this point in the history
The previous approach duplicated the implementation of `sequence`, which
is a slight code stink. More importantly though, this approach will
benefit from an optimized override implementation of `sequence` if the
`Traverse` instance has one.
  • Loading branch information
ceedubs committed Feb 16, 2016
1 parent 6dbd4b0 commit fd32422
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/Applicative.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ import simulacrum.typeclass
def traverse[A, G[_], B](value: G[A])(f: A => F[B])(implicit G: Traverse[G]): F[G[B]] =
G.traverse(value)(f)(this)

def sequence[G[_]: Traverse, A](as: G[F[A]]): F[G[A]] =
traverse(as)(a => a)
def sequence[G[_], A](as: G[F[A]])(implicit G: Traverse[G]): F[G[A]] =
G.sequence(as)(this)

}

Expand Down

0 comments on commit fd32422

Please sign in to comment.