Skip to content

Commit

Permalink
Merge pull request #772 from refried/oneand-reducible
Browse files Browse the repository at this point in the history
add Reducible instance for OneAnd, deprecate Foldable instance
  • Loading branch information
mpilquist committed Jan 30, 2016
2 parents 9780e8f + 7fe2d24 commit ba77953
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions core/src/main/scala/cats/data/OneAnd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,9 @@ private[data] sealed trait OneAndInstances extends OneAndLowPriority2 {
implicit def oneAndSemigroup[F[_]: MonadCombine, A]: Semigroup[OneAnd[F, A]] =
oneAndSemigroupK.algebra

implicit def oneAndFoldable[F[_]](implicit foldable: Foldable[F]): Foldable[OneAnd[F, ?]] =
new Foldable[OneAnd[F, ?]] {
override def foldLeft[A, B](fa: OneAnd[F, A], b: B)(f: (B, A) => B): B =
fa.foldLeft(b)(f)
override def foldRight[A, B](fa: OneAnd[F, A], lb: Eval[B])(f: (A, Eval[B]) => Eval[B]): Eval[B] =
fa.foldRight(lb)(f)
override def isEmpty[A](fa: OneAnd[F, A]): Boolean = false
implicit def oneAndReducible[F[_]](implicit F: Foldable[F]): Reducible[OneAnd[F, ?]] =
new NonEmptyReducible[OneAnd[F,?], F] {
override def split[A](fa: OneAnd[F,A]): (A, F[A]) = (fa.head, fa.tail)
}

implicit def oneAndMonad[F[_]](implicit monad: MonadCombine[F]): Monad[OneAnd[F, ?]] =
Expand Down

0 comments on commit ba77953

Please sign in to comment.