Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

change to GenIterable from Iterable #149

Closed
wants to merge 2 commits into from

2 participants

@xuwei-k
Collaborator

No description provided.

@larsrh

Since nobody else seems to have an opinion, here's mine: The problem I see is that this could be potentially unwanted, since GenIterable also includes ParIterable, which has quite a different semantics from plain Iterable (obviuosly). I think there are two possible solutions to this problem:

  • Not supporting ParIterable at all, which requires users to either define their own instances or calling .seq first.
  • Having a common implementation for both, but requiring separate imports.

The disadvantage of supporting ParIterable is that we would add even more non-determinism to our tests. I'm open for discussion, but I am opposed to this pull request as of now.

@larsrh larsrh closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 16, 2012
  1. @xuwei-k
  2. @xuwei-k

    fix typo

    xuwei-k authored
This page is out of date. Refresh to see the latest.
View
2  core/src/main/scala/scalaz/FingerTree.scala
@@ -869,7 +869,7 @@ trait FingerTreeInstances {
implicit def fingerTreeShow[V, A](implicit V: Show[V], A: Show[A]): Show[FingerTree[V,A]] = new Show[FingerTree[V,A]] {
import syntax.show._
- import std.iterable._
+ import std.list._
val AS = Show[List[A]]
import Cord._
override def show(t: FingerTree[V,A]) = t.fold(
View
2  core/src/main/scala/scalaz/std/AllInstances.scala
@@ -11,6 +11,6 @@ trait AllInstances
with scalaz.std.java.math.BigIntegerInstances
with scalaz.std.java.util.concurrent.CallableInstances
with NodeSeqInstances
- // Intentionally omitted: IterableInstances
+ // Intentionally omitted: GenIterableInstances
object AllInstances extends AllInstances
View
21 .../src/main/scala/scalaz/std/Iterable.scala → ...c/main/scala/scalaz/std/GenIterable.scala
@@ -1,15 +1,16 @@
package scalaz
package std
+import scala.collection.GenIterable
-trait IterableInstances {
+trait GenIterableInstances {
- implicit def iterableShow[CC[X] <: Iterable[X], A: Show]: Show[CC[A]] = new Show[CC[A]] {
- override def show(as: CC[A]) = "[" +: Cord.mkCord(",", as.map(Show[A].show(_)).toSeq:_*) :+ "]"
+ implicit def genIterableShow[CC[X] <: GenIterable[X], A: Show]: Show[CC[A]] = new Show[CC[A]] {
+ override def show(as: CC[A]) = "[" +: Cord.mkCord(",", as.map(Show[A].show(_)).toArray:_*) :+ "]"
}
/** Lexicographical ordering */
- implicit def iterableOrder[A](implicit A: Order[A]): Order[Iterable[A]] = new Order[Iterable[A]] {
- def order(a1: Iterable[A], a2: Iterable[A]): Ordering = {
+ implicit def genIterableOrder[A](implicit A: Order[A]): Order[GenIterable[A]] = new Order[GenIterable[A]] {
+ def order(a1: GenIterable[A], a2: GenIterable[A]): Ordering = {
import scalaz.Ordering._
val i1 = a1.iterator
val i2 = a2.iterator
@@ -27,8 +28,8 @@ trait IterableInstances {
}
}
- implicit def iterableLength: Length[Iterable] = new Length[Iterable] {
- def length[A](a: Iterable[A]) = {
+ implicit def genIterableLength: Length[GenIterable] = new Length[GenIterable] {
+ def length[A](a: GenIterable[A]) = {
var n = 0
val i = a.iterator
while (i.hasNext) {
@@ -39,7 +40,7 @@ trait IterableInstances {
}
}
- implicit def iterableEqual[CC[X] <: Iterable[X], A: Equal]: Equal[CC[A]] = new Equal[CC[A]] {
+ implicit def genIterableEqual[CC[X] <: GenIterable[X], A: Equal]: Equal[CC[A]] = new Equal[CC[A]] {
def equal(a1: CC[A], a2: CC[A]) = {
val i1 = a1.iterator
val i2 = a2.iterator
@@ -58,7 +59,7 @@ trait IterableInstances {
}
}
- implicit def iterableSubtypeTraverse[I[X] <: Iterable[X]]: Foldable[I] = new Foldable[I] {
+ implicit def genIterableSubtypeTraverse[I[X] <: GenIterable[X]]: Foldable[I] = new Foldable[I] {
def foldMap[A,B](fa: I[A])(f: A => B)(implicit F: Monoid[B]) = foldRight(fa, F.zero)((x,y) => Monoid[B].append(f(x), y))
def foldRight[A, B](fa: I[A], b: => B)(f: (A, => B) => B) = fa.foldRight(b)(f(_, _))
@@ -68,4 +69,4 @@ trait IterableInstances {
}
-object iterable extends IterableInstances
+object genIterable extends GenIterableInstances
View
4 .../test/scala/scalaz/std/IterableTest.scala → ...st/scala/scalaz/std/GenIterableTest.scala
@@ -7,7 +7,7 @@ import std.AllInstances._
class IterableTest extends Spec {
- import std.iterable._
+ import std.genIterable._
checkAll(order.laws[Iterable[Boolean]].withProp("benchmark", order.scalaOrdering[Iterable[Boolean]]))
-}
+}
Something went wrong with that request. Please try again.