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

Update sbt-scalafmt to 2.0.1 #2908

Merged
merged 3 commits into from
Jun 23, 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
3 changes: 3 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
version=2.0.0-RC8
align.openParenCallSite = true
align.openParenDefnSite = true
maxColumn = 120
continuationIndent.defnSite = 2
assumeStandardLibraryStripMargin = true
Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ lazy val catsSettings = Seq(
libraryDependencies ++= Seq(
"org.typelevel" %%% "machinist" % "0.6.8",
compilerPlugin("org.typelevel" %% "kind-projector" % kindProjectorVersion)
) ++ macroDependencies(scalaVersion.value),
) ++ macroDependencies(scalaVersion.value)
) ++ commonSettings ++ publishSettings ++ scoverageSettings ++ simulacrumSettings

lazy val simulacrumSettings = Seq(
Expand Down Expand Up @@ -304,7 +304,7 @@ def mimaSettings(moduleName: String) =
exclude[DirectMissingMethodProblem]("cats.data.KleisliInstances4.catsDataCommutativeFlatMapForKleisli"),
exclude[DirectMissingMethodProblem]("cats.data.IRWSTInstances1.catsDataStrongForIRWST"),
exclude[DirectMissingMethodProblem]("cats.data.OptionTInstances1.catsDataMonadErrorMonadForOptionT"),
exclude[DirectMissingMethodProblem]("cats.data.OptionTInstances1.catsDataMonadErrorForOptionT"),
exclude[DirectMissingMethodProblem]("cats.data.OptionTInstances1.catsDataMonadErrorForOptionT")
) ++
//These things are Ops classes that shouldn't have the `value` exposed. These should have never been public because they don't
//provide any value. Making them private because of issues like #2514 and #2613.
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 @@ -84,7 +84,7 @@ sealed abstract class Eval[+A] extends Serializable { self =>
type Start = A
val start = () => c.run(s)
val run = f
}
}
}
case c: Eval.Defer[A] =>
new Eval.FlatMap[B] {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/Foldable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ import Foldable.sentinel
f(a) match {
case Right(c) => (A.empty[B], A.pure(c))
case Left(b) => (A.pure(b), A.empty[C])
}
}
)
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/Monad.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import simulacrum.typeclass
}
},
ifFalse = pure(Right(xs))
)
)
)
}

Expand All @@ -53,7 +53,7 @@ import simulacrum.typeclass
map(b.value)(_ => continue)
},
ifFalse = stop
)
)
)
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/Reducible.scala
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ import simulacrum.typeclass
case (Right(c), _) => ior.map(c :: _)
case (Left(b), Ior.Right(r)) => Ior.bothNel(b, r)
case (Left(b), _) => ior.leftMap(b :: _)
}
}
)

reduceRightTo(fa)(a => f(a).bimap(NonEmptyList.one, NonEmptyList.one).toIor)(g).value
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/scala/cats/data/Chain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,9 @@ sealed abstract class Chain[+A] {
var first = true

foreach { a =>
if (first) { builder ++= AA.show(a); first = false } else builder ++= ", " + AA.show(a)
if (first) {
builder ++= AA.show(a); first = false
} else builder ++= ", " + AA.show(a)
()
}
builder += ')'
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/EitherT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ private[data] trait EitherTMonad[F[_], L] extends Monad[EitherT[F, L, ?]] with E
case Left(l) => Right(Left(l))
case Right(Left(a1)) => Left(a1)
case Right(Right(b)) => Right(Right(b))
}
}
)
)
}
Expand Down
17 changes: 9 additions & 8 deletions core/src/main/scala/cats/data/IndexedStateT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,13 @@ 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 =>
val sa = f(r)
val fsba = sfsa(sa)
F.map(fsba) { case (sb, a) => (g(r, sb), a) }
}
StateT.applyF(F.map(runF) {
sfsa =>
{ r: R =>
val sa = f(r)
val fsba = sfsa(sa)
F.map(fsba) { case (sb, a) => (g(r, sb), a) }
}
})

/**
Expand Down Expand Up @@ -438,7 +439,7 @@ sealed abstract private[data] class IndexedStateTMonad[F[_], S]
s =>
F.tailRecM[(S, A), (S, B)]((s, a)) {
case (s, a) => F.map(f(a).run(s)) { case (s, ab) => ab.bimap((s, _), (s, _)) }
}
}
)
}

Expand Down Expand Up @@ -475,7 +476,7 @@ sealed abstract private[data] class IndexedStateTContravariantMonoidal[F[_], S]
(tup: (S, A)) =>
f(tup._2) match {
case (b, c) => (G.pure((tup._1, b)), G.pure((tup._1, c)))
}
}
)(G, F)
)
)
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 @@ -481,7 +481,7 @@ private[data] trait KleisliArrowChoice[F[_]]
fe match {
case Left(a) => F.map(f(a))(Left.apply _)
case Right(b) => F.map(g(b))(Right.apply _)
}
}
)
}

Expand Down
7 changes: 5 additions & 2 deletions core/src/main/scala/cats/data/NonEmptyList.scala
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ final case class NonEmptyList[+A](head: A, tail: List[A]) {

val buf = ListBuffer.empty[AA]
tail.foldLeft(TreeSet(head: AA)) { (elementsSoFar, b) =>
if (elementsSoFar(b)) elementsSoFar else { buf += b; elementsSoFar + b }
if (elementsSoFar(b)) elementsSoFar
else {
buf += b; elementsSoFar + b
}
}

NonEmptyList(head, buf.toList)
Expand Down Expand Up @@ -592,7 +595,7 @@ sealed abstract private[data] class NonEmptyListInstances extends NonEmptyListIn
case (Right(c), _) => ior.map(c :: _)
case (Left(b), Ior.Right(r)) => Ior.bothNel(b, r)
case (Left(b), _) => ior.leftMap(b :: _)
}
}
)

}
Expand Down
7 changes: 5 additions & 2 deletions core/src/main/scala/cats/data/NonEmptyVector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,10 @@ final class NonEmptyVector[+A] private (val toVector: Vector[A]) extends AnyVal

val buf = Vector.newBuilder[AA]
tail.foldLeft(TreeSet(head: AA)) { (elementsSoFar, a) =>
if (elementsSoFar(a)) elementsSoFar else { buf += a; elementsSoFar + a }
if (elementsSoFar(a)) elementsSoFar
else {
buf += a; elementsSoFar + a
}
}

NonEmptyVector(head, buf.result())
Expand Down Expand Up @@ -315,7 +318,7 @@ sealed abstract private[data] class NonEmptyVectorInstances {
case (Right(c), _) => ior.map(_ :+ c)
case (Left(b), Ior.Right(_)) => ior.putLeft(NonEmptyVector.one(b))
case (Left(b), _) => ior.leftMap(_ :+ b)
}
}
).bimap(_.toNonEmptyList, _.toNonEmptyList)

}
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/data/OptionT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ private[data] trait OptionTMonad[F[_]] extends Monad[OptionT[F, ?]] {
a0 =>
F.map(f(a0).value)(
_.fold(Either.right[A, Option[B]](None))(_.map(b => Some(b): Option[B]))
)
)
)
)
}
Expand Down Expand Up @@ -405,7 +405,7 @@ private trait OptionTContravariantMonoidal[F[_]] extends ContravariantMonoidal[O
t match {
case Some((x, y)) => (Some(x), Some(y))
case None => (None, None)
}
}
)
)
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/WriterT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ sealed private[data] trait WriterTContravariantMonoidal[F[_], L] extends Contrav
(t: (L, (A, B))) =>
t match {
case (l, (a, b)) => ((l, a), (l, b))
}
}
)
)
}
Expand Down
30 changes: 15 additions & 15 deletions core/src/main/scala/cats/evidence/As.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ sealed abstract class As[-A, +B] extends Serializable {
* to a function, such as F in: `type F[-B] = B => String`. In this
* case, we could use A As B to turn an F[B] Into F[A].
*/
def substitute[F[- _]](p: F[B]): F[A]
def substitute[F[-_]](p: F[B]): F[A]

@inline final def andThen[C](that: (B As C)): (A As C) = As.compose(that, this)

Expand Down Expand Up @@ -56,7 +56,7 @@ object As extends AsInstances {
* single value.
*/
private[this] val reflAny = new (Any As Any) {
def substitute[F[- _]](fa: F[Any]) = fa
def substitute[F[-_]](fa: F[Any]) = fa
}

/**
Expand Down Expand Up @@ -94,30 +94,30 @@ object As extends AsInstances {
/**
* We can lift subtyping into any covariant type constructor
*/
def co[T[+ _], A, A2](a: A As A2): (T[A] As T[A2]) =
def co[T[+_], A, A2](a: A As A2): (T[A] As T[A2]) =
a.substitute[λ[`-α` => T[α] As T[A2]]](refl)

// Similarly, we can do this any time we find a covariant type
// parameter. Here we provide the proof for what we expect to be the
// most common shapes.

def co2[T[+ _, _], Z, A, B](a: A As Z): T[A, B] As T[Z, B] =
def co2[T[+_, _], Z, A, B](a: A As Z): T[A, B] As T[Z, B] =
a.substitute[λ[`-α` => T[α, B] As T[Z, B]]](refl)

/**
* Widen a F[X,+A] to a F[X,B] if (A As B). This can be used to widen
* the output of a Function1, for example.
*/
def co2_2[T[_, + _], Z, A, B](a: B As Z): T[A, B] As T[A, Z] =
def co2_2[T[_, +_], Z, A, B](a: B As Z): T[A, B] As T[A, Z] =
a.substitute[λ[`-α` => T[A, α] As T[A, Z]]](refl)

def co3[T[+ _, _, _], Z, A, B, C](a: A As Z): T[A, B, C] As T[Z, B, C] =
def co3[T[+_, _, _], Z, A, B, C](a: A As Z): T[A, B, C] As T[Z, B, C] =
a.substitute[λ[`-α` => T[α, B, C] As T[Z, B, C]]](refl)

def co3_2[T[_, + _, _], Z, A, B, C](a: B As Z): T[A, B, C] As T[A, Z, C] =
def co3_2[T[_, +_, _], Z, A, B, C](a: B As Z): T[A, B, C] As T[A, Z, C] =
a.substitute[λ[`-α` => T[A, α, C] As T[A, Z, C]]](refl)

def co3_3[T[+ _, _, + _], Z, A, B, C](a: C As Z): T[A, B, C] As T[A, B, Z] =
def co3_3[T[+_, _, +_], Z, A, B, C](a: C As Z): T[A, B, C] As T[A, B, Z] =
a.substitute[λ[`-α` => T[A, B, α] As T[A, B, Z]]](refl)

/**
Expand All @@ -131,7 +131,7 @@ object As extends AsInstances {
*
* lift2(a,b) = co1_2(a) compose co2_2(b)
*/
def lift2[T[+ _, + _], A, A2, B, B2](
def lift2[T[+_, +_], A, A2, B, B2](
a: A As A2,
b: B As B2
): (T[A, B] As T[A2, B2]) = {
Expand All @@ -147,26 +147,26 @@ object As extends AsInstances {
* Given that F has the shape: F[-_], we show that:
* (A As B) implies (F[B] As F[A])
*/
def contra[T[- _], A, B](a: A As B): (T[B] As T[A]) =
def contra[T[-_], A, B](a: A As B): (T[B] As T[A]) =
a.substitute[λ[`-α` => T[B] As T[α]]](refl)

// Similarly, we can do this any time we find a contravariant type
// parameter. Here we provide the proof for what we expect to be the
// most common shapes.

def contra1_2[T[- _, _], Z, A, B](a: A As Z): (T[Z, B] As T[A, B]) =
def contra1_2[T[-_, _], Z, A, B](a: A As Z): (T[Z, B] As T[A, B]) =
a.substitute[λ[`-α` => T[Z, B] As T[α, B]]](refl)

def contra2_2[T[_, - _], Z, A, B](a: B As Z): (T[A, Z] As T[A, B]) =
def contra2_2[T[_, -_], Z, A, B](a: B As Z): (T[A, Z] As T[A, B]) =
a.substitute[λ[`-α` => T[A, Z] As T[A, α]]](refl)

def contra1_3[T[- _, _, _], Z, A, B, C](a: A As Z): (T[Z, B, C] As T[A, B, C]) =
def contra1_3[T[-_, _, _], Z, A, B, C](a: A As Z): (T[Z, B, C] As T[A, B, C]) =
a.substitute[λ[`-α` => T[Z, B, C] As T[α, B, C]]](refl)

def contra2_3[T[_, - _, _], Z, A, B, C](a: B As Z): (T[A, Z, C] As T[A, B, C]) =
def contra2_3[T[_, -_, _], Z, A, B, C](a: B As Z): (T[A, Z, C] As T[A, B, C]) =
a.substitute[λ[`-α` => T[A, Z, C] As T[A, α, C]]](refl)

def contra3_3[T[_, _, - _], Z, A, B, C](a: C As Z): (T[A, B, Z] As T[A, B, C]) =
def contra3_3[T[_, _, -_], Z, A, B, C](a: C As Z): (T[A, B, Z] As T[A, B, C]) =
a.substitute[λ[`-α` => T[A, B, Z] As T[A, B, α]]](refl)

/**
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/instances/function.scala
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ sealed private[instances] trait Function1Instances extends Function1Instances0 {
(ab: (A, B)) =>
ab match {
case (a, b) => Monoid[R].combine(fa(a), fb(b))
}
}
}

implicit def catsStdMonadForFunction1[T1]: Monad[T1 => ?] =
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/instances/list.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ trait ListInstances extends cats.kernel.instances.ListInstances {
f(a) match {
case Left(b) => (b :: acc._1, acc._2)
case Right(c) => (acc._1, c :: acc._2)
}
}
)

@tailrec
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/syntax/foldable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ final class FoldableOps[F[_], A](private val fa: F[A]) extends AnyVal {
f(a) match {
case Some(x) => M.combine(acc, x)
case None => acc
}
}
)
}

Expand Down Expand Up @@ -356,7 +356,7 @@ final class FoldableOps1[F[_]](private val F: Foldable[F]) extends AnyVal {
a =>
M.map(f(a)) {
H.bifoldMap[B, C, (F[B], F[C])](_)(b => (A.pure(b), A.empty[C]), c => (A.empty[B], A.pure(c)))
}
}
)
}

Expand Down
4 changes: 2 additions & 2 deletions free/src/test/scala/cats/free/CofreeSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class CofreeSuite extends CatsSuite {
} else {
spooky.increment()
Some(spooky.counter)
}
}
)
spooky.counter should ===(0)
incrementor.forceAll
Expand Down Expand Up @@ -163,7 +163,7 @@ sealed trait CofreeSuiteInstances {
(l.head, l.tail) match {
case (h, Nil) => nelToCofNel(NonEmptyList(h, Nil))
case (h, t) => nelToCofNel(NonEmptyList(h, t))
}
}
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trait DoubleInstances {

class DoubleGroup extends CommutativeGroup[Double] {
def combine(x: Double, y: Double): Double = x + y
def empty: Double = 0D
def empty: Double = 0d
def inverse(x: Double): Double = -x
override def remove(x: Double, y: Double): Double = x - y
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ trait FloatInstances {
*/
class FloatGroup extends CommutativeGroup[Float] {
def combine(x: Float, y: Float): Float = x + y
def empty: Float = 0F
def empty: Float = 0f
def inverse(x: Float): Float = -x
override def remove(x: Float, y: Float): Float = x - y
}
Expand Down
Loading