Skip to content
Closed
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 .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version=2.0.1
version=2.1.0
align.openParenCallSite = true
align.openParenDefnSite = true
maxColumn = 120
continuationIndent.defnSite = 2
assumeStandardLibraryStripMargin = true
danglingParentheses = true
rewrite.rules = [AvoidInfix, SortImports, RedundantBraces, RedundantParens, SortModifiers]
docstrings = JavaDoc
docstrings = JavaDoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package cats.data

private[data] trait ScalaVersionSpecificNonEmptyChainImpl {
def fromSeq[A](as: scala.collection.Seq[A]): Option[NonEmptyChain[A]] =
if (as.nonEmpty) Option(NonEmptyChainImpl.create(Chain.fromSeq(as))) else None
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package cats.data

private[data] trait ScalaVersionSpecificNonEmptyChainImpl {
def fromSeq[A](as: scala.collection.Seq[A]): Option[NonEmptyChain[A]] =
if (as.nonEmpty) Option(NonEmptyChainImpl.create(Chain.fromSeq(as))) else None
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package cats.data

private[data] trait ScalaVersionSpecificNonEmptyChainImpl
6 changes: 2 additions & 4 deletions core/src/main/scala/cats/data/NonEmptyChain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ import NonEmptyChainImpl.create
import cats.{Order, Semigroup}
import cats.kernel._

import scala.collection.immutable._

private[data] object NonEmptyChainImpl extends NonEmptyChainInstances {
private[data] object NonEmptyChainImpl extends NonEmptyChainInstances with ScalaVersionSpecificNonEmptyChainImpl {
// The following 3 types are components of a technique to
// create a no-boxing newtype. It's coped from the
// newtypes lib by @alexknvl
Expand Down Expand Up @@ -52,7 +50,7 @@ private[data] object NonEmptyChainImpl extends NonEmptyChainInstances {
def fromNonEmptyVector[A](as: NonEmptyVector[A]): NonEmptyChain[A] =
create(Chain.fromSeq(as.toVector))

def fromSeq[A](as: Seq[A]): Option[NonEmptyChain[A]] =
def fromSeq[A](as: scala.collection.immutable.Seq[A]): Option[NonEmptyChain[A]] =
if (as.nonEmpty) Option(create(Chain.fromSeq(as))) else None

def fromChainPrepend[A](a: A, ca: Chain[A]): NonEmptyChain[A] =
Expand Down
6 changes: 4 additions & 2 deletions core/src/main/scala/cats/data/NonEmptyList.scala
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,10 @@ sealed abstract private[data] class NonEmptyListInstances extends NonEmptyListIn

implicit val catsDataInstancesForNonEmptyList
: SemigroupK[NonEmptyList] with Bimonad[NonEmptyList] with NonEmptyTraverse[NonEmptyList] =
new NonEmptyReducible[NonEmptyList, List] with SemigroupK[NonEmptyList] with Bimonad[NonEmptyList]
with NonEmptyTraverse[NonEmptyList] {
new NonEmptyReducible[NonEmptyList, List]
with SemigroupK[NonEmptyList]
with Bimonad[NonEmptyList]
with NonEmptyTraverse[NonEmptyList] {

def combineK[A](a: NonEmptyList[A], b: NonEmptyList[A]): NonEmptyList[A] =
a.concatNel(b)
Expand Down
6 changes: 4 additions & 2 deletions core/src/main/scala/cats/data/NonEmptyVector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,10 @@ sealed abstract private[data] class NonEmptyVectorInstances {

implicit val catsDataInstancesForNonEmptyVector
: SemigroupK[NonEmptyVector] with Bimonad[NonEmptyVector] with NonEmptyTraverse[NonEmptyVector] =
new NonEmptyReducible[NonEmptyVector, Vector] with SemigroupK[NonEmptyVector] with Bimonad[NonEmptyVector]
with NonEmptyTraverse[NonEmptyVector] {
new NonEmptyReducible[NonEmptyVector, Vector]
with SemigroupK[NonEmptyVector]
with Bimonad[NonEmptyVector]
with NonEmptyTraverse[NonEmptyVector] {

def combineK[A](a: NonEmptyVector[A], b: NonEmptyVector[A]): NonEmptyVector[A] =
a.concatNev(b)
Expand Down
7 changes: 5 additions & 2 deletions core/src/main/scala/cats/instances/option.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ trait OptionInstances extends cats.kernel.instances.OptionInstances {
with Alternative[Option]
with CommutativeMonad[Option]
with CoflatMap[Option] =
new Traverse[Option] with MonadError[Option, Unit] with Alternative[Option] with CommutativeMonad[Option]
with CoflatMap[Option] {
new Traverse[Option]
with MonadError[Option, Unit]
with Alternative[Option]
with CommutativeMonad[Option]
with CoflatMap[Option] {

def empty[A]: Option[A] = None

Expand Down
10 changes: 5 additions & 5 deletions laws/src/main/scala/cats/laws/discipline/MiniInt.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ object MiniInt {

val allValues: List[MiniInt] = (minIntValue to maxIntValue).map(unsafeFromInt).toList

implicit val catsLawsEqInstancesForMiniInt: Order[MiniInt] with Hash[MiniInt] = new Order[MiniInt]
with Hash[MiniInt] {
def hash(x: MiniInt): Int = Hash[Int].hash(x.intBits)
implicit val catsLawsEqInstancesForMiniInt: Order[MiniInt] with Hash[MiniInt] =
new Order[MiniInt] with Hash[MiniInt] {
def hash(x: MiniInt): Int = Hash[Int].hash(x.intBits)

def compare(x: MiniInt, y: MiniInt): Int = Order[Int].compare(x.toInt, y.toInt)
}
def compare(x: MiniInt, y: MiniInt): Int = Order[Int].compare(x.toInt, y.toInt)
}

implicit val catsLawsExhaustiveCheckForMiniInt: ExhaustiveCheck[MiniInt] =
ExhaustiveCheck.instance(allValues)
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.1")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "0.6.1")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.28")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.3.9")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.4")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.2.1")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")

/* Temporarily disabling sbt-hydra, see #2870.
Expand Down
2 changes: 1 addition & 1 deletion tests/src/test/scala/cats/tests/NonEmptyChainSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class NonEmptyChainSuite extends CatsSuite {

test("fromSeq . toList . iterator is id") {
forAll { (ci: NonEmptyChain[Int]) =>
NonEmptyChain.fromSeq(ci.iterator.toList) should ===(Option(ci))
NonEmptyChain.fromSeq(ci.iterator.toSeq) should ===(Option(ci))
}
}

Expand Down