Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Foldable1 primitives #512

Merged
merged 7 commits into from Sep 8, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions core/src/main/scala/scalaz/Foldable.scala
Expand Up @@ -78,12 +78,20 @@ trait Foldable[F[_]] { self =>

/**Curried version of `foldRight` */
final def foldr[A, B](fa: F[A], z: => B)(f: A => (=> B) => B): B = foldRight(fa, z)((a, b) => f(a)(b))
def foldRight1Opt[A](fa: F[A])(f: (A, => A) => A): Option[A] = foldRight(fa, None: Option[A])((a, optA) => optA map (aa => f(a, aa)) orElse Some(a))
def foldMapRight1Opt[A, B](fa: F[A])(z: A => B)(f: (A, => B) => B): Option[B] =
foldRight(fa, None: Option[B])((a, optB) =>
optB map (f(a, _)) orElse Some(z(a)))
def foldRight1Opt[A](fa: F[A])(f: (A, => A) => A): Option[A] =
foldMapRight1Opt(fa)(conforms)(f)
def foldr1Opt[A](fa: F[A])(f: A => (=> A) => A): Option[A] = foldr(fa, None: Option[A])(a => optA => optA map (aa => f(a)(aa)) orElse Some(a))

/**Curried version of `foldLeft` */
final def foldl[A, B](fa: F[A], z: B)(f: B => A => B) = foldLeft(fa, z)((b, a) => f(b)(a))
def foldLeft1Opt[A](fa: F[A])(f: (A, A) => A): Option[A] = foldLeft(fa, None: Option[A])((optA, a) => optA map (aa => f(aa, a)) orElse Some(a))
def foldMapLeft1Opt[A, B](fa: F[A])(z: A => B)(f: (B, A) => B): Option[B] =
foldLeft(fa, None: Option[B])((optB, a) =>
optB map (f(_, a)) orElse Some(z(a)))
def foldLeft1Opt[A](fa: F[A])(f: (A, A) => A): Option[A] =
foldMapLeft1Opt(fa)(conforms)(f)
def foldl1Opt[A](fa: F[A])(f: A => A => A): Option[A] = foldl(fa, None: Option[A])(optA => a => optA map (aa => f(aa)(a)) orElse Some(a))

/**Curried version of `foldRightM` */
Expand Down
67 changes: 33 additions & 34 deletions core/src/main/scala/scalaz/Foldable1.scala
Expand Up @@ -21,28 +21,44 @@ trait Foldable1[F[_]] extends Foldable[F] { self =>
override def foldMap1Opt[A,B](fa: F[A])(f: A => B)(implicit F: Semigroup[B]): Option[B] = Some(foldMap1(fa)(f))

/**Right-associative fold of a structure. */
def foldRight1[A](fa: F[A])(f: (A, => A) => A): A
def foldMapRight1[A, B](fa: F[A])(z: A => B)(f: (A, => B) => B): B

// derived functions
override def foldMap[A,B](fa: F[A])(f: A => B)(implicit F: Monoid[B]): B =
foldMap1(fa)(f)

/**Right-associative fold of a structure. */
def foldRight1[A](fa: F[A])(f: (A, => A) => A): A =
foldMapRight1(fa)(conforms)(f)

override def foldRight[A, B](fa: F[A], z: => B)(f: (A, => B) => B): B =
foldMapRight1(fa)(f(_, z))(f)

/**Left-associative fold of a structure. */
def foldLeft1[A](fa: F[A])(f: (A, A) => A): A = {
def foldMapLeft1[A, B](fa: F[A])(z: A => B)(f: (B, A) => B): B = {
import std.option._
foldLeft(fa, none[A]) {
case (None, r) => some(r)
foldLeft(fa, none[B]) {
case (None, r) => some(z(r))
case (Some(l), r) => some(f(l, r))
}.getOrElse(sys.error("foldLeft1"))
}.getOrElse(sys.error("foldMapLeft1"))
}

/**Left-associative fold of a structure. */
def foldLeft1[A](fa: F[A])(f: (A, A) => A): A =
foldMapLeft1(fa)(conforms)(f)

// XXX Would make a ⊥ with default foldMapLeft1; you can use it if
// you also overrode foldMapLeft1
// override def foldLeft[A, B](fa: F[A], z: B)(f: (B, A) => B): B =
// foldMapLeft1(fa)(f(z, _))(f)

/** Curried `foldRight1`. */
final def foldr1[A](fa: F[A])(f: A => (=> A) => A): A = foldRight1(fa)((a, b) => f(a)(b))
override def foldRight1Opt[A](fa: F[A])(f: (A, => A) => A): Option[A] = Some(foldRight1(fa)(f))
override def foldMapRight1Opt[A, B](fa: F[A])(z: A => B)(f: (A, => B) => B): Option[B] = Some(foldMapRight1(fa)(z)(f))
override def foldr1Opt[A](fa: F[A])(f: A => (=> A) => A): Option[A] = Some(foldr1(fa)(f))
/** Curried `foldLeft1`. */
final def foldl1[A](fa: F[A])(f: A => A => A): A = foldLeft1(fa)((b, a) => f(b)(a))
override def foldLeft1Opt[A](fa: F[A])(f: (A, A) => A): Option[A] = Some(foldLeft1(fa)(f))
override def foldMapLeft1Opt[A, B](fa: F[A])(z: A => B)(f: (B, A) => B): Option[B] = Some(foldMapLeft1(fa)(z)(f))
override def foldl1Opt[A](fa: F[A])(f: A => A => A): Option[A] = Some(foldl1(fa)(f))

def fold1[M: Semigroup](t: F[M]): M = foldMap1[M, M](t)(identity)
Expand Down Expand Up @@ -90,34 +106,17 @@ trait Foldable1[F[_]] extends Foldable[F] { self =>
}

trait Foldable1Law extends FoldableLaw {
import scalaz.Id._
type Pair[A] = (A, A)
private[this] implicit lazy val pfunc: Functor[Pair] = // probably not eager-val-safe
Functor[Id].product[Id]

/** In a left-fold, the accumulator is always on the left. */
def leftFold1Bias[A](fa: F[Free.Return[Pair, A]]
)(implicit up: F[Free.Return[Pair, A]] => F[Free[Pair, A]]): Boolean = {
@annotation.tailrec def rec(fpa: Free[Pair, A]): Boolean =
fpa.resume.leftMap{case (a, b) => (a, b.resume)} match {
case -\/((l, \/-(r))) => rec(l)
case -\/(_) => false
case \/-(_) => true
}
rec(foldLeft1(up(fa))((l, r) => Free.Suspend[Pair, A]((l, r))))
}
import std.vector._

/** In a right-fold, the accumulator is always on the right. */
def rightFold1Bias[A](fa: F[Free.Return[Pair, A]]
)(implicit up: F[Free.Return[Pair, A]] => F[Free[Pair, A]]): Boolean = {
@annotation.tailrec def rec(fpa: Free[Pair, A]): Boolean =
fpa.resume.leftMap{case (a, b) => (a.resume, b)} match {
case -\/((\/-(l), r)) => rec(r)
case -\/(_) => false
case \/-(_) => true
}
rec(foldRight1(up(fa))((l, r) => Free.Suspend[Pair, A]((l, r))))
}
/** Left fold is consistent with foldMap1. */
def leftFM1Consistent[A: Equal](fa: F[A]): Boolean =
Equal[Vector[A]].equal(foldMap1(fa)(Vector(_)),
foldMapLeft1(fa)(Vector(_))(_ :+ _))

/** Right fold is consistent with foldMap1. */
def rightFM1Consistent[A: Equal](fa: F[A]): Boolean =
Equal[Vector[A]].equal(foldMap1(fa)(Vector(_)),
foldMapRight1(fa)(Vector(_))(_ +: _))
}
def foldable1Law = new Foldable1Law {}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/scalaz/Id.scala
Expand Up @@ -37,7 +37,7 @@ trait IdInstances {

override def foldRight[A, B](fa: Id[A], z: => B)(f: (A, => B) => B): B = f(fa, z)

override def foldRight1[A](fa: Id[A])(f: (A, => A) => A): A = fa
override def foldMapRight1[A, B](fa: Id[A])(z: A => B)(f: (A, => B) => B): B = z(fa)

// Overrides for efficiency.

Expand Down
10 changes: 4 additions & 6 deletions core/src/main/scala/scalaz/NonEmptyList.scala
Expand Up @@ -134,15 +134,13 @@ sealed abstract class NonEmptyListInstances extends NonEmptyListInstances0 {
def traverse1Impl[G[_] : Apply, A, B](fa: NonEmptyList[A])(f: A => G[B]): G[NonEmptyList[B]] =
fa traverse1 f

override def foldRight1[A](fa: NonEmptyList[A])(f: (A, => A) => A): A = {
override def foldMapRight1[A, B](fa: NonEmptyList[A])(z: A => B)(f: (A, => B) => B): B = {
val reversed = fa.reverse
reversed.tail.foldLeft(reversed.head)((x, y) => f(y, x))
reversed.tail.foldLeft(z(reversed.head))((x, y) => f(y, x))
}

override def foldLeft1[A](fa: NonEmptyList[A])(f: (A, A) => A): A = fa.tail match {
case Nil => fa.head
case h :: t => foldLeft1(NonEmptyList.nel(f(fa.head, h), t))(f)
}
override def foldMapLeft1[A, B](fa: NonEmptyList[A])(z: A => B)(f: (B, A) => B): B =
fa.tail.foldLeft(z(fa.head))(f)

override def foldMap1[A, B](fa: NonEmptyList[A])(f: A => B)(implicit F: Semigroup[B]): B = {
fa.tail.foldLeft(f(fa.head))((x, y) => F.append(x, f(y)))
Expand Down
14 changes: 7 additions & 7 deletions core/src/main/scala/scalaz/OneAnd.scala
Expand Up @@ -69,12 +69,12 @@ private sealed trait OneAndFoldable[F[_]]
override def foldMap1[A, B: Semigroup](fa: OneAnd[F, A])(f: A => B) =
foldMap(fa)(a => some(f(a))) getOrElse f(fa.head)

override def foldRight1[A](fa: OneAnd[F, A])(f: (A, => A) => A) =
(F.foldRight(fa.tail, none[A])((a, oa) => oa map (f(a, _)) orElse some(a))
map (f(fa.head, _)) getOrElse fa.head)
override def foldMapRight1[A, B](fa: OneAnd[F, A])(z: A => B)(f: (A, => B) => B) =
(F.foldRight(fa.tail, none[B])((a, ob) => ob map (f(a, _)) orElse some(z(a)))
map (f(fa.head, _)) getOrElse z(fa.head))

override def foldLeft1[A](fa: OneAnd[F, A])(f: (A, A) => A) =
F.foldLeft(fa.tail, fa.head)(f)
override def foldMapLeft1[A, B](fa: OneAnd[F, A])(z: A => B)(f: (B, A) => B) =
F.foldLeft(fa.tail, z(fa.head))(f)

override def foldMap[A, B](fa: OneAnd[F, A])(f: A => B)(implicit M: Monoid[B]) =
M.append(f(fa.head), F.foldMap(fa.tail)(f))
Expand All @@ -92,8 +92,8 @@ private sealed trait OneAndFoldable1[F[_]] extends OneAndFoldable[F] {
override def foldMap1[A, B](fa: OneAnd[F, A])(f: A => B)(implicit S: Semigroup[B]) =
S.append(f(fa.head), F.foldMap1(fa.tail)(f))

override def foldRight1[A](fa: OneAnd[F, A])(f: (A, => A) => A) =
f(fa.head, F.foldRight1(fa.tail)(f))
override def foldMapRight1[A, B](fa: OneAnd[F, A])(z: A => B)(f: (A, => B) => B) =
f(fa.head, F.foldMapRight1(fa.tail)(z)(f))
}

private sealed trait OneAndTraverse[F[_]]
Expand Down
20 changes: 10 additions & 10 deletions core/src/main/scala/scalaz/OneOr.scala
Expand Up @@ -74,20 +74,20 @@ final case class OneOr[F[_], A](run: F[A] \/ A) {
F.foldMap1(a)(f)
}

def foldRight1(f: (A, => A) => A)(implicit F: Foldable1[F]): A =
def foldMapRight1[B](z: A => B)(f: (A, => B) => B)(implicit F: Foldable1[F]): B =
run match {
case \/-(a) =>
a
z(a)
case -\/(a) =>
F.foldRight1(a)(f)
F.foldMapRight1(a)(z)(f)
}

def foldLeft1(f: (A, A) => A)(implicit F: Foldable1[F]): A =
def foldMapLeft1[B](z: A => B)(f: (B, A) => B)(implicit F: Foldable1[F]): B =
run match {
case \/-(a) =>
a
z(a)
case -\/(a) =>
F.foldLeft1(a)(f)
F.foldMapLeft1(a)(z)(f)
}

def traverse[G[_], B](f: A => G[B])(implicit T: Traverse[F], F: Applicative[G]): G[OneOr[F, B]] =
Expand Down Expand Up @@ -170,11 +170,11 @@ private sealed trait OneOrFoldable1[F[_]]
override def foldMap1[A, B](fa: OneOr[F, A])(f: A => B)(implicit M: Semigroup[B]) =
fa.foldMap1(f)

override def foldRight1[A](fa: OneOr[F, A])(f: (A, => A) => A) =
fa.foldRight1(f)
override def foldMapRight1[A, B](fa: OneOr[F, A])(z: A => B)(f: (A, => B) => B) =
fa.foldMapRight1(z)(f)

override def foldLeft1[A](fa: OneOr[F, A])(f: (A, A) => A) =
fa.foldLeft1(f)
override def foldMapLeft1[A, B](fa: OneOr[F, A])(z: A => B)(f: (B, A) => B) =
fa.foldMapLeft1(z)(f)
}

private sealed trait OneOrTraverse[F[_]]
Expand Down
24 changes: 12 additions & 12 deletions core/src/main/scala/scalaz/Product.scala
Expand Up @@ -68,46 +68,46 @@ private trait ProductFoldable[F[_], G[_]] extends Foldable[({type λ[α] = (F[α
private trait ProductFoldable1L[F[_], G[_]] extends Foldable1[({type λ[α] = (F[α], G[α])})#λ] with ProductFoldable[F, G] {
implicit def F: Foldable1[F]

override def foldRight1[A](fa: (F[A], G[A]))(f: (A, => A) => A): A =
cata(G.foldRight1Opt(fa._2)(f))(F.foldRight(fa._1, _)(f), F.foldRight1(fa._1)(f))
override def foldMapRight1[A, B](fa: (F[A], G[A]))(z: A => B)(f: (A, => B) => B): B =
cata(G.foldMapRight1Opt(fa._2)(z)(f))(F.foldRight(fa._1, _)(f), F.foldMapRight1(fa._1)(z)(f))

override def foldMap1[A,B](fa: (F[A], G[A]))(f: A => B)(implicit S: Semigroup[B]): B = {
val resume = F.foldMap1(fa._1)(f)
cata(G.foldMap1Opt(fa._2)(f))(S.append(resume, _), resume)
}

override def foldLeft1[A](fa: (F[A], G[A]))(f: (A, A) => A): A =
G.foldLeft(fa._2, F.foldLeft1(fa._1)(f))(f)
override def foldMapLeft1[A, B](fa: (F[A], G[A]))(z: A => B)(f: (B, A) => B): B =
G.foldLeft(fa._2, F.foldMapLeft1(fa._1)(z)(f))(f)
}

private trait ProductFoldable1R[F[_], G[_]] extends Foldable1[({type λ[α] = (F[α], G[α])})#λ] with ProductFoldable[F, G] {
implicit def G: Foldable1[G]

override def foldRight1[A](fa: (F[A], G[A]))(f: (A, => A) => A): A =
F.foldRight(fa._1, G.foldRight1(fa._2)(f))(f)
override def foldMapRight1[A, B](fa: (F[A], G[A]))(z: A => B)(f: (A, => B) => B): B =
F.foldRight(fa._1, G.foldMapRight1(fa._2)(z)(f))(f)

override def foldMap1[A,B](fa: (F[A], G[A]))(f: A => B)(implicit S: Semigroup[B]): B = {
def resume = G.foldMap1(fa._2)(f)
cata(F.foldMap1Opt(fa._1)(f))(S.append(_, resume), resume)
}

override def foldLeft1[A](fa: (F[A], G[A]))(f: (A, A) => A): A =
cata(F.foldLeft1Opt(fa._1)(f))(G.foldLeft(fa._2, _)(f), G.foldLeft1(fa._2)(f))
override def foldMapLeft1[A, B](fa: (F[A], G[A]))(z: A => B)(f: (B, A) => B): B =
cata(F.foldMapLeft1Opt(fa._1)(z)(f))(G.foldLeft(fa._2, _)(f), G.foldMapLeft1(fa._2)(z)(f))
}

private trait ProductFoldable1[F[_], G[_]] extends Foldable1[({type λ[α] = (F[α], G[α])})#λ] with ProductFoldable[F, G] {
implicit def F: Foldable1[F]

implicit def G: Foldable1[G]

override def foldRight1[A](fa: (F[A], G[A]))(f: (A, => A) => A): A =
F.foldRight(fa._1, G.foldRight1(fa._2)(f))(f)
override def foldMapRight1[A, B](fa: (F[A], G[A]))(z: A => B)(f: (A, => B) => B): B =
F.foldRight(fa._1, G.foldMapRight1(fa._2)(z)(f))(f)

override def foldMap1[A,B](fa: (F[A], G[A]))(f: A => B)(implicit S: Semigroup[B]): B =
S.append(F.foldMap1(fa._1)(f), G.foldMap1(fa._2)(f))

override def foldLeft1[A](fa: (F[A], G[A]))(f: (A, A) => A): A =
G.foldLeft(fa._2, F.foldLeft1(fa._1)(f))(f)
override def foldMapLeft1[A, B](fa: (F[A], G[A]))(z: A => B)(f: (B, A) => B): B =
G.foldLeft(fa._2, F.foldMapLeft1(fa._1)(z)(f))(f)
}

private trait ProductTraverse[F[_], G[_]] extends Traverse[({type λ[α] = (F[α], G[α])})#λ] with ProductFunctor[F, G] with ProductFoldable[F, G] {
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala/scalaz/Tree.scala
Expand Up @@ -124,11 +124,11 @@ sealed abstract class TreeInstances {
def bind[A, B](fa: Tree[A])(f: A => Tree[B]): Tree[B] = fa flatMap f
def traverse1Impl[G[_]: Apply, A, B](fa: Tree[A])(f: A => G[B]): G[Tree[B]] = fa traverse1 f
override def foldRight[A, B](fa: Tree[A], z: => B)(f: (A, => B) => B): B = fa.foldRight(z)(f)
override def foldRight1[A](fa: Tree[A])(f: (A, => A) => A): A = fa.subForest.foldRight(fa.rootLabel)((t, a) => treeInstance.foldRight(t, a)(f))
override def foldMapRight1[A, B](fa: Tree[A])(z: A => B)(f: (A, => B) => B): B = fa.subForest.foldRight(z(fa.rootLabel))((t, b) => treeInstance.foldRight(t, b)(f))
override def foldLeft[A, B](fa: Tree[A], z: B)(f: (B, A) => B): B =
fa.flatten.foldLeft(z)(f)
override def foldLeft1[A](fa: Tree[A])(f: (A, A) => A): A = fa.flatten match {
case h #:: t => t.foldLeft(h)(f)
override def foldMapLeft1[A, B](fa: Tree[A])(z: A => B)(f: (B, A) => B): B = fa.flatten match {
case h #:: t => t.foldLeft(z(h))(f)
}
override def foldMap[A, B](fa: Tree[A])(f: A => B)(implicit F: Monoid[B]): B = fa foldMap f
}
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/scala/scalaz/syntax/Foldable1Syntax.scala
Expand Up @@ -5,6 +5,8 @@ package syntax
sealed abstract class Foldable1Ops[F[_],A] extends Ops[F[A]] {
implicit def F: Foldable1[F]
////
final def foldMapRight1[B](z: A => B)(f: (A, => B) => B): B = F.foldMapRight1(self)(z)(f)
final def foldMapLeft1[B](z: A => B)(f: (B, A) => B): B = F.foldMapLeft1(self)(z)(f)
final def foldRight1(f: (A, => A) => A): A = F.foldRight1(self)(f)
final def foldLeft1(f: (A, A) => A): A = F.foldLeft1(self)(f)
final def foldr1(f: A => (=> A) => A): A = F.foldr1(self)(f)
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/scala/scalaz/syntax/FoldableSyntax.scala
Expand Up @@ -12,8 +12,10 @@ sealed abstract class FoldableOps[F[_],A] extends Ops[F[A]] {
final def foldMap[B: Monoid](f: A => B = (a: A) => a): B = F.foldMap(self)(f)
final def foldMap1Opt[B: Semigroup](f: A => B = (a: A) => a): Option[B] = F.foldMap1Opt(self)(f)
final def foldRight[B](z: => B)(f: (A, => B) => B): B = F.foldRight(self, z)(f)
final def foldMapRight1Opt[B](z: A => B)(f: (A, => B) => B): Option[B] = F.foldMapRight1Opt(self)(z)(f)
final def foldRight1Opt(f: (A, => A) => A): Option[A] = F.foldRight1Opt(self)(f)
final def foldLeft[B](z: B)(f: (B, A) => B): B = F.foldLeft(self, z)(f)
final def foldMapLeft1Opt[B](z: A => B)(f: (B, A) => B): Option[B] = F.foldMapLeft1Opt(self)(z)(f)
final def foldLeft1Opt(f: (A, A) => A): Option[A] = F.foldLeft1Opt(self)(f)
final def foldRightM[G[_], B](z: => B)(f: (A, => B) => G[B])(implicit M: Monad[G]): G[B] = F.foldRightM(self, z)(f)
final def foldLeftM[G[_], B](z: B)(f: (B, A) => G[B])(implicit M: Monad[G]): G[B] = F.foldLeftM(self, z)(f)
Expand Down
Expand Up @@ -137,9 +137,6 @@ object ScalazArbitrary {

implicit def ArraySeqArbitrary[A](implicit a: Arbitrary[A]): Arbitrary[ArraySeq[A]] = Functor[Arbitrary].map(arb[List[A]])(x => ArraySeq(x: _*))

implicit def FreeReturnArbitrary[F[_], A](implicit F: Functor[F], a: Arbitrary[A]): Arbitrary[Free.Return[F, A]] =
Functor[Arbitrary].map(a)(Free.Return[F, A](_))

import FingerTree._

implicit def FingerArbitrary[V, A](implicit a: Arbitrary[A], measure: Reducer[A, V]): Arbitrary[Finger[V, A]] = Arbitrary(oneOf(
Expand Down
Expand Up @@ -329,18 +329,18 @@ object ScalazProperties {
object foldable1 {
type Pair[A] = (A, A)

def leftFold1Bias[F[_], A](implicit F: Foldable1[F], fa: Arbitrary[F[Free.Return[Pair, A]]], up: F[Free.Return[Pair, A]] => F[Free[Pair, A]]) =
forAll(F.foldable1Law.leftFold1Bias[A] _)
def leftFM1Consistent[F[_], A](implicit F: Foldable1[F], fa: Arbitrary[F[A]], ea: Equal[A]) =
forAll(F.foldable1Law.leftFM1Consistent[A] _)

def rightFold1Bias[F[_], A](implicit F: Foldable1[F], fa: Arbitrary[F[Free.Return[Pair, A]]], up: F[Free.Return[Pair, A]] => F[Free[Pair, A]]) =
forAll(F.foldable1Law.rightFold1Bias[A] _)
def rightFM1Consistent[F[_], A](implicit F: Foldable1[F], fa: Arbitrary[F[A]], ea: Equal[A]) =
forAll(F.foldable1Law.rightFM1Consistent[A] _)

def laws[F[_]](implicit fa: Arbitrary[F[Int]], afrpa: Arbitrary[F[Free.Return[Pair, Int]]],
F: Foldable1[F], EA: Equal[Int], up: F[Free.Return[Pair, Int]] => F[Free[Pair, Int]]) =
def laws[F[_]](implicit fa: Arbitrary[F[Int]],
F: Foldable1[F], EA: Equal[Int]) =
new Properties("foldable1") {
include(foldable.laws[F])
property("left fold accumulates on left") = leftFold1Bias[F, Int]
property("right fold accumulates on right") = rightFold1Bias[F, Int]
property("consistent left fold1") = leftFM1Consistent[F, Int]
property("consistent right fold1") = rightFM1Consistent[F, Int]
}
}

Expand All @@ -362,13 +362,6 @@ object ScalazProperties {

def laws[F[_]](implicit fa: Arbitrary[F[Int]], F: Traverse1[F], EF: Equal[F[Int]]) =
new Properties("traverse1") {
import ScalaCheckBinding.ArbitraryMonad
private[this] implicit def frpi: Arbitrary[F[Free.Return[foldable1.Pair, Int]]] =
Functor[Arbitrary].map(fa)(F.map(_)(Free.Return[foldable1.Pair, Int](_)(Functor[Id].product[Id])))
private[this] implicit def upfrpi(xs: F[Free.Return[foldable1.Pair, Int]]
): F[Free[foldable1.Pair, Int]] =
F.map(xs)(conforms)

include(traverse.laws[F])
include(foldable1.laws[F])
property("identity traverse1") = identityTraverse1[F, Int, Int]
Expand Down