Skip to content

Commit

Permalink
Adding size and get for EitherK
Browse files Browse the repository at this point in the history
  • Loading branch information
yilinwei committed May 14, 2017
1 parent d94f5e8 commit 40426c4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/src/main/scala/cats/data/EitherK.scala
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@ private[data] trait EitherKFoldable[F[_], G[_]] extends Foldable[EitherK[F, G, ?
def foldLeft[A, B](fa: EitherK[F, G, A], z: B)(f: (B, A) => B): B =
fa.foldLeft(z)(f)

override def size[A](fa: EitherK[F, G, A]): Long =
fa.run.fold(F.size, G.size)

override def get[A](fa: EitherK[F, G, A])(idx: Long) =
fa.run.fold(F.get(_)(idx), G.get(_)(idx))

override def foldMap[A, B](fa: EitherK[F, G, A])(f: A => B)(implicit M: Monoid[B]): B =
fa foldMap f
}
Expand Down

0 comments on commit 40426c4

Please sign in to comment.