Skip to content

Commit

Permalink
Remove redundant type annotation.
Browse files Browse the repository at this point in the history
  • Loading branch information
takayahilton committed Aug 8, 2019
1 parent 709bb56 commit 86636fe
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 29 deletions.
7 changes: 4 additions & 3 deletions core/src/main/scala/cats/data/AbstractNonEmptyInstances.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ abstract private[data] class AbstractNonEmptyInstances[F[_], NonEmptyF[_]](impli
CF: CoflatMap[F],
TF: Traverse[F],
SF: SemigroupK[F])
extends Bimonad[NonEmptyF]
extends NonEmptyReducible[NonEmptyF, F]
with Bimonad[NonEmptyF]
with NonEmptyTraverse[NonEmptyF]
with SemigroupK[NonEmptyF] {
val monadInstance = MF.asInstanceOf[Monad[NonEmptyF]]
Expand Down Expand Up @@ -35,10 +36,10 @@ abstract private[data] class AbstractNonEmptyInstances[F[_], NonEmptyF[_]](impli
def tailRecM[A, B](a: A)(f: A => NonEmptyF[Either[A, B]]): NonEmptyF[B] =
monadInstance.tailRecM(a)(f)

def foldLeft[A, B](fa: NonEmptyF[A], b: B)(f: (B, A) => B): B =
override def foldLeft[A, B](fa: NonEmptyF[A], b: B)(f: (B, A) => B): B =
traverseInstance.foldLeft(fa, b)(f)

def foldRight[A, B](fa: NonEmptyF[A], lb: Eval[B])(f: (A, Eval[B]) => Eval[B]): Eval[B] =
override def foldRight[A, B](fa: NonEmptyF[A], lb: Eval[B])(f: (A, Eval[B]) => Eval[B]): Eval[B] =
traverseInstance.foldRight(fa, lb)(f)

override def foldMap[A, B](fa: NonEmptyF[A])(f: A => B)(implicit B: Monoid[B]): B =
Expand Down
8 changes: 6 additions & 2 deletions core/src/main/scala/cats/data/NonEmptyChain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,16 @@ sealed abstract private[data] class NonEmptyChainInstances extends NonEmptyChain
override def reduce[A](fa: NonEmptyChain[A])(implicit A: Semigroup[A]): A =
fa.reduce

def reduceLeftTo[A, B](fa: NonEmptyChain[A])(f: A => B)(g: (B, A) => B): B = fa.reduceLeftTo(f)(g)
override def reduceLeftTo[A, B](fa: NonEmptyChain[A])(f: A => B)(g: (B, A) => B): B = fa.reduceLeftTo(f)(g)

def reduceRightTo[A, B](fa: NonEmptyChain[A])(f: A => B)(g: (A, cats.Eval[B]) => cats.Eval[B]): cats.Eval[B] =
override def reduceRightTo[A, B](
fa: NonEmptyChain[A]
)(f: A => B)(g: (A, cats.Eval[B]) => cats.Eval[B]): cats.Eval[B] =
Eval.defer(fa.reduceRightTo(a => Eval.now(f(a))) { (a, b) =>
Eval.defer(g(a, b))
})

def split[A](fa: NonEmptyChain[A]): (A, Chain[A]) = fa.uncons
}

implicit def catsDataOrderForNonEmptyChain[A: Order]: Order[NonEmptyChain[A]] =
Expand Down
21 changes: 9 additions & 12 deletions core/src/main/scala/cats/data/NonEmptyList.scala
Original file line number Diff line number Diff line change
Expand Up @@ -506,14 +506,11 @@ object NonEmptyList extends NonEmptyListInstances {

sealed abstract private[data] class NonEmptyListInstances extends NonEmptyListInstances0 {

implicit val catsDataInstancesForNonEmptyList: SemigroupK[NonEmptyList]
with Reducible[NonEmptyList]
with Bimonad[NonEmptyList]
with NonEmptyTraverse[NonEmptyList] =
new NonEmptyReducible[NonEmptyList, List] with SemigroupK[NonEmptyList] with Bimonad[NonEmptyList]
with NonEmptyTraverse[NonEmptyList] {

def combineK[A](a: NonEmptyList[A], b: NonEmptyList[A]): NonEmptyList[A] =
implicit val catsDataInstancesForNonEmptyList
: SemigroupK[NonEmptyList] with Bimonad[NonEmptyList] with NonEmptyTraverse[NonEmptyList] =
new AbstractNonEmptyInstances[List, NonEmptyList] {

override def combineK[A](a: NonEmptyList[A], b: NonEmptyList[A]): NonEmptyList[A] =
a.concatNel(b)

override def split[A](fa: NonEmptyList[A]): (A, List[A]) = (fa.head, fa.tail)
Expand All @@ -527,13 +524,13 @@ sealed abstract private[data] class NonEmptyListInstances extends NonEmptyListIn
override def map[A, B](fa: NonEmptyList[A])(f: A => B): NonEmptyList[B] =
fa.map(f)

def pure[A](x: A): NonEmptyList[A] =
override def pure[A](x: A): NonEmptyList[A] =
NonEmptyList.one(x)

def flatMap[A, B](fa: NonEmptyList[A])(f: A => NonEmptyList[B]): NonEmptyList[B] =
override def flatMap[A, B](fa: NonEmptyList[A])(f: A => NonEmptyList[B]): NonEmptyList[B] =
fa.flatMap(f)

def coflatMap[A, B](fa: NonEmptyList[A])(f: NonEmptyList[A] => B): NonEmptyList[B] =
override def coflatMap[A, B](fa: NonEmptyList[A])(f: NonEmptyList[A] => B): NonEmptyList[B] =
fa.coflatMap(f)

def extract[A](fa: NonEmptyList[A]): A = fa.head
Expand Down Expand Up @@ -563,7 +560,7 @@ sealed abstract private[data] class NonEmptyListInstances extends NonEmptyListIn
override def foldMap[A, B](fa: NonEmptyList[A])(f: A => B)(implicit B: Monoid[B]): B =
B.combineAll(fa.toList.iterator.map(f))

def tailRecM[A, B](a: A)(f: A => NonEmptyList[Either[A, B]]): NonEmptyList[B] = {
override def tailRecM[A, B](a: A)(f: A => NonEmptyList[Either[A, B]]): NonEmptyList[B] = {
val buf = new ListBuffer[B]
@tailrec def go(v: NonEmptyList[Either[A, B]]): Unit = v.head match {
case Right(b) =>
Expand Down
21 changes: 9 additions & 12 deletions core/src/main/scala/cats/data/NonEmptyVector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,11 @@ final class NonEmptyVector[+A] private (val toVector: Vector[A]) extends AnyVal
@suppressUnusedImportWarningForScalaVersionSpecific
sealed abstract private[data] class NonEmptyVectorInstances {

implicit val catsDataInstancesForNonEmptyVector: SemigroupK[NonEmptyVector]
with Reducible[NonEmptyVector]
with Bimonad[NonEmptyVector]
with NonEmptyTraverse[NonEmptyVector] =
new NonEmptyReducible[NonEmptyVector, Vector] with SemigroupK[NonEmptyVector] with Bimonad[NonEmptyVector]
with NonEmptyTraverse[NonEmptyVector] {

def combineK[A](a: NonEmptyVector[A], b: NonEmptyVector[A]): NonEmptyVector[A] =
implicit val catsDataInstancesForNonEmptyVector
: SemigroupK[NonEmptyVector] with Bimonad[NonEmptyVector] with NonEmptyTraverse[NonEmptyVector] =
new AbstractNonEmptyInstances[Vector, NonEmptyVector] {

override def combineK[A](a: NonEmptyVector[A], b: NonEmptyVector[A]): NonEmptyVector[A] =
a.concatNev(b)

override def split[A](fa: NonEmptyVector[A]): (A, Vector[A]) = (fa.head, fa.tail)
Expand All @@ -261,13 +258,13 @@ sealed abstract private[data] class NonEmptyVectorInstances {
override def map[A, B](fa: NonEmptyVector[A])(f: A => B): NonEmptyVector[B] =
fa.map(f)

def pure[A](x: A): NonEmptyVector[A] =
override def pure[A](x: A): NonEmptyVector[A] =
NonEmptyVector.one(x)

def flatMap[A, B](fa: NonEmptyVector[A])(f: A => NonEmptyVector[B]): NonEmptyVector[B] =
override def flatMap[A, B](fa: NonEmptyVector[A])(f: A => NonEmptyVector[B]): NonEmptyVector[B] =
fa.flatMap(f)

def coflatMap[A, B](fa: NonEmptyVector[A])(f: NonEmptyVector[A] => B): NonEmptyVector[B] = {
override def coflatMap[A, B](fa: NonEmptyVector[A])(f: NonEmptyVector[A] => B): NonEmptyVector[B] = {
@tailrec def consume(as: Vector[A], buf: VectorBuilder[B]): Vector[B] =
as match {
case a +: as => consume(as, buf += f(NonEmptyVector(a, as)))
Expand Down Expand Up @@ -329,7 +326,7 @@ sealed abstract private[data] class NonEmptyVectorInstances {
override def get[A](fa: NonEmptyVector[A])(idx: Long): Option[A] =
if (0 <= idx && idx < Int.MaxValue) fa.get(idx.toInt) else None

def tailRecM[A, B](a: A)(f: A => NonEmptyVector[Either[A, B]]): NonEmptyVector[B] = {
override def tailRecM[A, B](a: A)(f: A => NonEmptyVector[Either[A, B]]): NonEmptyVector[B] = {
val buf = new VectorBuilder[B]
@tailrec def go(v: NonEmptyVector[Either[A, B]]): Unit = v.head match {
case Right(b) =>
Expand Down

0 comments on commit 86636fe

Please sign in to comment.