Skip to content

Commit

Permalink
address feedback / removed duplicated class
Browse files Browse the repository at this point in the history
  • Loading branch information
kailuowang committed Oct 23, 2017
1 parent c0a3cc2 commit a6e85dd
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 46 deletions.
15 changes: 2 additions & 13 deletions alleycats-core/src/main/scala/alleycats/std/iterable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,8 @@ object IterableInstances {
new Foldable[Iterable] {
override def foldLeft[A, B](fa: Iterable[A], b: B)(f: (B, A) => B): B = fa.foldLeft(b)(f)

// based upon foldRight of List in Cats
override def foldRight[A, B](fa: Iterable[A], lb: Eval[B])(f: (A, Eval[B]) => Eval[B]): Eval[B] = {
def loop(as: Iterable[A]): Eval[B] =
if (as.isEmpty)
lb
else {
val h = as.head
val t = as.tail
f(h, Eval.defer(loop(t)))
}
Eval.defer(loop(fa))
}

override def foldRight[A, B](fa: Iterable[A], lb: Eval[B])(f: (A, Eval[B]) => Eval[B]): Eval[B] =
Foldable.iterateRight(fa, lb)(f)
}

}
Expand Down
2 changes: 1 addition & 1 deletion alleycats-core/src/main/scala/alleycats/std/set.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ object SetInstances {
def foldLeft[A, B](fa: Set[A], b: B)(f: (B, A) => B): B =
fa.foldLeft(b)(f)
def foldRight[A, B](fa: Set[A], lb: Eval[B])(f: (A, Eval[B]) => Eval[B]): Eval[B] =
Foldable.iterateRight(fa.iterator, lb)(f)
Foldable.iterateRight(fa, lb)(f)
def traverse[G[_]: Applicative, A, B](sa: Set[A])(f: A => G[B]): G[Set[B]] = {
val G = Applicative[G]
sa.foldLeft(G.pure(Set.empty[B])) { (buf, a) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ object foldable extends FoldableSyntax
trait FoldableSyntax {
implicit class ExtraFoldableOps[F[_]: Foldable, A](fa: F[A]) {
def foreach(f: A => Unit): Unit =
fa.foldLeft(()) { (unit, a) => f(a); unit }
fa.foldLeft(()) { (_, a) => f(a) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import catalysts.Platform
import cats._
import cats.instances.AllInstances
import cats.syntax.{AllSyntax, EqOps}

import cats.tests.StrictCatsEquality
import org.scalactic.anyvals.{PosZDouble, PosInt, PosZInt}
import org.scalatest.{FunSuite, Matchers}
import org.scalatest.prop.{Configuration, GeneratorDrivenPropertyChecks}
Expand Down
30 changes: 0 additions & 30 deletions alleycats-tests/src/test/scala/alleycats/tests/CatsEquality.scala

This file was deleted.

0 comments on commit a6e85dd

Please sign in to comment.