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

Parenthesize lambda parameters with type annotations #3182

Merged
merged 1 commit into from
Dec 2, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/Composed.scala
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private[cats] trait ComposedSemigroupal[F[_], G[_]]
def G: Functor[G]

def product[A, B](fa: F[G[A]], fb: F[G[B]]): F[G[(A, B)]] =
F.contramap(F.product(fa, fb)) { g: G[(A, B)] =>
F.contramap(F.product(fa, fb)) { (g: G[(A, B)]) =>
(G.map(g)(_._1), G.map(g)(_._2))
}
}
Expand All @@ -167,7 +167,7 @@ private[cats] trait ComposedInvariantApplySemigroupal[F[_], G[_]]
F.imap(F.product(fa, fb)) {
case (ga, gb) =>
G.map2(ga, gb)(_ -> _)
} { g: G[(A, B)] =>
} { (g: G[(A, B)]) =>
(G.map(g)(_._1), G.map(g)(_._2))
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/Eval.scala
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ object Eval extends EvalInstances {
type M = Memoize[Any]
type C = Any => Eval[Any]

def addToMemo(m: M): C = { a: Any =>
def addToMemo(m: M): C = { (a: Any) =>
m.result = Some(a)
Now(a)
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/Representable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private trait RepresentableMonad[F[_], R] extends Monad[F] {
R.tabulate(a => R.index(f(R.index(fa)(a)))(a))

override def tailRecM[A, B](a: A)(f: A => F[Either[A, B]]): F[B] =
R.tabulate { r: R =>
R.tabulate { (r: R) =>
@annotation.tailrec
def loop(a: A): B =
R.index(f(a))(r) match {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/ContT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ object ContT {
DeferCont(() => FromFn(AndThen(fn)))

def tailRecM[M[_], A, B, C](a: A)(fn: A => ContT[M, C, Either[A, B]])(implicit M: Defer[M]): ContT[M, C, B] =
ContT[M, C, B] { cb: (B => M[C]) =>
ContT[M, C, B] { (cb: (B => M[C])) =>
def go(a: A): M[C] =
fn(a).run {
case Left(a) => M.defer(go(a))
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/data/Func.scala
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ sealed abstract class AppFunc[F[_], A, B] extends Func[F, A, B] { self =>
def product[G[_]](g: AppFunc[G, A, B]): AppFunc[λ[α => Tuple2K[F, G, α]], A, B] = {
implicit val FF: Applicative[F] = self.F
implicit val GG: Applicative[G] = g.F
Func.appFunc[λ[α => Tuple2K[F, G, α]], A, B] { a: A =>
Func.appFunc[λ[α => Tuple2K[F, G, α]], A, B] { (a: A) =>
Tuple2K(self.run(a), g.run(a))
}
}

def compose[G[_], C](g: AppFunc[G, C, A]): AppFunc[Nested[G, F, *], C, B] = {
implicit val gfApplicative: Applicative[Nested[G, F, *]] = Nested.catsDataApplicativeForNested[G, F](g.F, F)
Func.appFunc[Nested[G, F, *], C, B]({ c: C =>
Func.appFunc[Nested[G, F, *], C, B]({ (c: C) =>
Nested(g.F.map(g.run(c))(self.run))
})
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/IndexedStateT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ final class IndexedStateT[F[_], SA, SB, A](val runF: F[SA => F[(SB, A)]]) extend
def transformS[R](f: R => SA, g: (R, SB) => R)(implicit F: Functor[F]): IndexedStateT[F, R, R, A] =
StateT.applyF(F.map(runF) {
sfsa =>
{ r: R =>
{ (r: R) =>
val sa = f(r)
val fsba = sfsa(sa)
F.map(fsba) { case (sb, a) => (g(r, sb), a) }
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/Kleisli.scala
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ private[data] trait KleisliApplicativeError[F[_], A, E]

def raiseError[B](e: E): K[B] = Kleisli(_ => F.raiseError(e))

def handleErrorWith[B](kb: K[B])(f: E => K[B]): K[B] = Kleisli { a: A =>
def handleErrorWith[B](kb: K[B])(f: E => K[B]): K[B] = Kleisli { (a: A) =>
F.handleErrorWith(kb.run(a))((e: E) => f(e).run(a))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class FreeInvariantMonoidalSuite extends CatsSuite {
SerializableTests.serializable(InvariantMonoidal[FreeInvariantMonoidal[BinCodec, *]]))

test("FreeInvariantMonoidal#fold") {
forAll { i1: BinCodec[MiniInt] =>
forAll { (i1: BinCodec[MiniInt]) =>
val n = MiniInt.unsafeFromInt(2)
val i2 = InvariantMonoidal[BinCodec].point(n)
val iExpr = i1.product(i2.imap(_ * n)(_ / n))
Expand Down
6 changes: 3 additions & 3 deletions free/src/test/scala/cats/free/FreeSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ class FreeSuite extends CatsSuite {
}

test("compile id") {
forAll { x: Free[List, Int] =>
forAll { (x: Free[List, Int]) =>
x.compile(FunctionK.id[List]) should ===(x)
val fk = Free.compile(FunctionK.id[List])
fk(x) === x
}
}

test("defer doesn't change value") {
forAll { x: Free[List, Int] =>
forAll { (x: Free[List, Int]) =>
Free.defer(x) should ===(x)
}
}
Expand All @@ -66,7 +66,7 @@ class FreeSuite extends CatsSuite {
}

test("compile consistent with foldMap") {
forAll { x: Free[List, Int] =>
forAll { (x: Free[List, Int]) =>
val mapped = x.compile(headOptionU)
val folded = mapped.foldMap(FunctionK.id[Option])
folded should ===(x.foldMap(headOptionU))
Expand Down
6 changes: 3 additions & 3 deletions free/src/test/scala/cats/free/FreeTSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class FreeTSuite extends CatsSuite {
}

test("mapK to universal id equivalent to original instance") {
forAll { a: FreeTOption[Int] =>
forAll { (a: FreeTOption[Int]) =>
val b = a.mapK(FunctionK.id)
Eq[FreeTOption[Int]].eqv(a, b) should ===(true)
}
Expand All @@ -93,7 +93,7 @@ class FreeTSuite extends CatsSuite {
}

test("compile to universal id equivalent to original instance") {
forAll { a: FreeTOption[Int] =>
forAll { (a: FreeTOption[Int]) =>
val b = a.compile(FunctionK.id)
Eq[FreeTOption[Int]].eqv(a, b) should ===(true)
val fk = FreeT.compile[Option, Option, Option](FunctionK.id)
Expand All @@ -109,7 +109,7 @@ class FreeTSuite extends CatsSuite {
}

test("foldMap consistent with runM") {
forAll { a: FreeTOption[Int] =>
forAll { (a: FreeTOption[Int]) =>
val x = a.runM(identity)
val y = a.foldMap(FunctionK.id)
val fk = FreeT.foldMap[Option, Option](FunctionK.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ class Tests extends AnyFunSuiteLike with Discipline with ScalaVersionSpecificTes
// The `Eq[Order[N]]` instance enumerates all possible `N` values in a
// `Vector` and considers two `Order[N]` instances to be equal if they
// result in the same sorting of that vector.
implicit val NOrderEq: Eq[Order[N]] = Eq.by { order: Order[N] =>
implicit val NOrderEq: Eq[Order[N]] = Eq.by { (order: Order[N]) =>
Vector.tabulate(nMax)(N).sorted(order.toOrdering)
}
implicit val NEqEq: Eq[Eq[N]] = new Eq[Eq[N]] {
Expand Down
4 changes: 2 additions & 2 deletions tests/src/test/scala/cats/tests/AndThenSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ class AndThenSuite extends CatsSuite {

test("andThen is stack safe") {
val count = if (Platform.isJvm) 500000 else 1000
val fs = (0 until count).map(_ => { i: Int => i + 1 })
val fs = (0 until count).map(_ => { (i: Int) => i + 1 })
val result = fs.foldLeft(AndThen((x: Int) => x))(_.andThen(_))(42)

result shouldEqual (count + 42)
}

test("compose is stack safe") {
val count = if (Platform.isJvm) 500000 else 1000
val fs = (0 until count).map(_ => { i: Int => i + 1 })
val fs = (0 until count).map(_ => { (i: Int) => i + 1 })
val result = fs.foldLeft(AndThen((x: Int) => x))(_.compose(_))(42)

result shouldEqual (count + 42)
Expand Down
2 changes: 1 addition & 1 deletion tests/src/test/scala/cats/tests/BinestedSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class BinestedSuite extends CatsSuite {
}

test("simple syntax-based usage") {
forAll { value: (Option[Int], List[Int]) =>
forAll { (value: (Option[Int], List[Int])) =>
value.binested.bimap(_.toString, _.toString).value should ===(value.bimap(_.map(_.toString), _.map(_.toString)))
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/test/scala/cats/tests/BitSetSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BitSetSuite extends CatsSuite {
BitSet(1, 1, 2, 3).show should ===("BitSet(1, 2, 3)")
BitSet.empty.show should ===("BitSet()")

forAll { fs: BitSet =>
forAll { (fs: BitSet) =>
fs.show should ===(fs.toString)
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/src/test/scala/cats/tests/ChainSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ChainSuite extends CatsSuite {
test("show") {
Show[Chain[Int]].show(Chain(1, 2, 3)) should ===("Chain(1, 2, 3)")
Chain.empty[Int].show should ===("Chain()")
forAll { l: Chain[String] =>
forAll { (l: Chain[String]) =>
l.show should ===(l.toString)
}
}
Expand Down Expand Up @@ -215,7 +215,7 @@ class ChainSuite extends CatsSuite {
}

test("Chain#distinct is consistent with List#distinct") {
forAll { a: Chain[Int] =>
forAll { (a: Chain[Int]) =>
a.distinct.toList should ===(a.toList.distinct)
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/test/scala/cats/tests/ConstSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class ConstSuite extends CatsSuite {

Const(1).show should ===("Const(1)")

forAll { const: Const[Int, String] =>
forAll { (const: Const[Int, String]) =>
const.show.startsWith("Const(") should ===(true)
const.show.contains(const.getConst.show)
const.show should ===(implicitly[Show[Const[Int, String]]].show(const))
Expand Down
14 changes: 7 additions & 7 deletions tests/src/test/scala/cats/tests/EitherSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class EitherSuite extends CatsSuite {
}

test("fromTry is left for failed Try") {
forAll { t: Try[Int] =>
forAll { (t: Try[Int]) =>
t.isFailure should ===(Either.fromTry(t).isLeft)
}
}
Expand All @@ -120,13 +120,13 @@ class EitherSuite extends CatsSuite {
}

test("leftNel is consistent with left(NEL)") {
forAll { s: String =>
forAll { (s: String) =>
Either.leftNel[String, Int](s) should ===(Either.left[NonEmptyList[String], Int](NonEmptyList.one(s)))
}
}

test("rightNel is consistent with right") {
forAll { i: Int =>
forAll { (i: Int) =>
Either.rightNel[String, Int](i) should ===(Either.right[NonEmptyList[String], Int](i))
}
}
Expand All @@ -138,23 +138,23 @@ class EitherSuite extends CatsSuite {
}

test("leftNec is consistent with left(NEC)") {
forAll { s: String =>
forAll { (s: String) =>
Either.leftNec[String, Int](s) should ===(Either.left[NonEmptyChain[String], Int](NonEmptyChain.one(s)))
}
}
test("rightNec is consistent with right") {
forAll { i: Int =>
forAll { (i: Int) =>
Either.rightNec[String, Int](i) should ===(Either.right[NonEmptyChain[String], Int](i))
}
}

test("leftNes is consistent with left(NES)") {
forAll { s: String =>
forAll { (s: String) =>
Either.leftNes[String, Int](s) should ===(Either.left[NonEmptySet[String], Int](NonEmptySet.one(s)))
}
}
test("rightNes is consistent with right") {
forAll { i: Int =>
forAll { (i: Int) =>
Either.rightNes[String, Int](i) should ===(Either.right[NonEmptySet[String], Int](i))
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/test/scala/cats/tests/IndexedStateTSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ class IndexedStateTSuite extends CatsSuite {
}

test("untilDefinedM works") {
val counter = State { i: Int =>
val counter = State { (i: Int) =>
val res = if (i > stackSafeTestSize) Some(i) else None
(i + 1, res)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/test/scala/cats/tests/IorSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class IorSuite extends CatsSuite {
}

test("Option roundtrip") {
forAll { ior: String Ior Int =>
forAll { (ior: String Ior Int) =>
val iorMaybe = Ior.fromOptions(ior.left, ior.right)
iorMaybe should ===(Some(ior))
}
Expand Down
4 changes: 2 additions & 2 deletions tests/src/test/scala/cats/tests/ListSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ListSuite extends CatsSuite {
checkAll("ZipList[Int]", CommutativeApplyTests[ZipList].commutativeApply[Int, Int, Int])

test("nel => list => nel returns original nel")(
forAll { fa: NonEmptyList[Int] =>
forAll { (fa: NonEmptyList[Int]) =>
fa.toList.toNel should ===(Some(fa))
}
)
Expand All @@ -60,7 +60,7 @@ class ListSuite extends CatsSuite {
test("show") {
List(1, 2, 3).show should ===("List(1, 2, 3)")
(Nil: List[Int]).show should ===("List()")
forAll { l: List[String] =>
forAll { (l: List[String]) =>
l.show should ===(l.toString)
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/src/test/scala/cats/tests/MiniIntSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ class MiniIntSuite extends CatsSuite {
}

test("int roundtrip") {
forAll { i: MiniInt =>
forAll { (i: MiniInt) =>
MiniInt.fromInt(i.toInt) should ===(Some(i))
}
}

test("int bounds") {
forAll(Gen.chooseNum(MiniInt.minIntValue, MiniInt.maxIntValue)) { i: Int =>
forAll(Gen.chooseNum(MiniInt.minIntValue, MiniInt.maxIntValue)) { (i: Int) =>
MiniInt.fromInt(i).map(_.toInt) should ===(Some(i))
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/src/test/scala/cats/tests/NonEmptyChainSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,19 @@ class NonEmptyChainSuite extends CatsSuite {
}

test("NonEmptyChain#distinct is consistent with List#distinct") {
forAll { ci: NonEmptyChain[Int] =>
forAll { (ci: NonEmptyChain[Int]) =>
ci.distinct.toList should ===(ci.toList.distinct)
}
}

test("init") {
forAll { ci: NonEmptyChain[Int] =>
forAll { (ci: NonEmptyChain[Int]) =>
ci.init.toList should ===(ci.toList.init)
}
}

test("last") {
forAll { ci: NonEmptyChain[Int] =>
forAll { (ci: NonEmptyChain[Int]) =>
ci.last should ===(ci.toList.last)
}
}
Expand Down
Loading