Skip to content
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
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/NonEmptyList.scala
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ final case class NonEmptyList[A](head: A, tail: List[A]) {
}

object NonEmptyList extends NonEmptyListInstances {
def apply[A](head: A, tail: A*): NonEmptyList[A] = NonEmptyList(head, tail.toList)
def of[A](head: A, tail: A*): NonEmptyList[A] = NonEmptyList(head, tail.toList)

/**
* Create a `NonEmptyList` from a `List`.
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/NonEmptyVector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ object NonEmptyVector extends NonEmptyVectorInstances {
def apply[A](head: A, tail: Vector[A]): NonEmptyVector[A] =
new NonEmptyVector(head +: tail)

def apply[A](head: A, tail: A*): NonEmptyVector[A] = {
def of[A](head: A, tail: A*): NonEmptyVector[A] = {
val buf = Vector.newBuilder[A]
buf += head
tail.foreach(buf += _)
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/Validated.scala
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ private[data] sealed abstract class ValidatedInstances2 {
trait ValidatedFunctions {
def invalid[A, B](a: A): Validated[A, B] = Validated.Invalid(a)

def invalidNel[A, B](a: A): ValidatedNel[A, B] = Validated.Invalid(NonEmptyList(a))
def invalidNel[A, B](a: A): ValidatedNel[A, B] = Validated.Invalid(NonEmptyList(a, Nil))

def valid[A, B](b: B): Validated[A, B] = Validated.Valid(b)

Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala/cats/data/XorT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ final case class XorT[F[_], A, B](value: F[A Xor B]) {
* {{{
* scala> import cats.implicits._
* scala> type Error = String
* scala> val v1: Validated[NonEmptyList[Error], Int] = Validated.Invalid(NonEmptyList("error 1"))
* scala> val v2: Validated[NonEmptyList[Error], Int] = Validated.Invalid(NonEmptyList("error 2"))
* scala> val v1: Validated[NonEmptyList[Error], Int] = Validated.Invalid(NonEmptyList.of("error 1"))
* scala> val v2: Validated[NonEmptyList[Error], Int] = Validated.Invalid(NonEmptyList.of("error 2"))
* scala> val xort: XorT[Option, Error, Int] = XorT(Some(Xor.left("error 3")))
* scala> xort.withValidated { v3 => (v1 |@| v2 |@| v3.leftMap(NonEmptyList(_))).map{ case (i, j, k) => i + j + k } }
* scala> xort.withValidated { v3 => (v1 |@| v2 |@| v3.leftMap(NonEmptyList.of(_))).map{ case (i, j, k) => i + j + k } }
* res0: XorT[Option, NonEmptyList[Error], Int] = XorT(Some(Left(NonEmptyList(error 1, error 2, error 3))))
* }}}
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/src/test/scala/cats/tests/NonEmptyListTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class NonEmptyListTests extends CatsSuite {
test("Creating NonEmptyList + toList is identity") {
forAll { (i: Int, tail: List[Int]) =>
val list = i :: tail
val nonEmptyList = NonEmptyList(i, tail: _*)
val nonEmptyList = NonEmptyList.of(i, tail: _*)
list should === (nonEmptyList.toList)
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/src/test/scala/cats/tests/NonEmptyVectorTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class NonEmptyVectorTests extends CatsSuite {
val v1 = NonEmptyVector("Test", Vector.empty)
v1.show should === ("NonEmptyVector(Test)")

val v2 = NonEmptyVector("foo", "bar", "baz")
val v2 = NonEmptyVector.of("foo", "bar", "baz")
v2.show should === ("NonEmptyVector(foo, bar, baz)")
}

Expand Down Expand Up @@ -185,9 +185,9 @@ class NonEmptyVectorTests extends CatsSuite {
}
}

test("NonEmptyVector#apply on varargs is consistent with NonEmptyVector#apply on Vector") {
test("NonEmptyVector#of on varargs is consistent with NonEmptyVector#apply on Vector") {
forAll { (head: Int, tail: Vector[Int]) =>
NonEmptyVector(head, tail:_*) should === (NonEmptyVector(head, tail))
NonEmptyVector.of(head, tail:_*) should === (NonEmptyVector(head, tail))
}
}

Expand Down
8 changes: 4 additions & 4 deletions tests/src/test/scala/cats/tests/RegressionTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,19 @@ class RegressionTests extends CatsSuite {
intMap.traverseU(validate) should === (Xor.left("6 is greater than 5"))
checkAndResetCount(3)

NonEmptyList(1,2,6,8).traverseU(validate) should === (Xor.left("6 is greater than 5"))
NonEmptyList.of(1,2,6,8).traverseU(validate) should === (Xor.left("6 is greater than 5"))
checkAndResetCount(3)

NonEmptyList(6,8).traverseU(validate) should === (Xor.left("6 is greater than 5"))
NonEmptyList.of(6,8).traverseU(validate) should === (Xor.left("6 is greater than 5"))
checkAndResetCount(1)

List(1,2,6,8).traverseU_(validate) should === (Xor.left("6 is greater than 5"))
checkAndResetCount(3)

NonEmptyList(1,2,6,7,8).traverseU_(validate) should === (Xor.left("6 is greater than 5"))
NonEmptyList.of(1,2,6,7,8).traverseU_(validate) should === (Xor.left("6 is greater than 5"))
checkAndResetCount(3)

NonEmptyList(6,7,8).traverseU_(validate) should === (Xor.left("6 is greater than 5"))
NonEmptyList.of(6,7,8).traverseU_(validate) should === (Xor.left("6 is greater than 5"))
checkAndResetCount(1)
}
}
4 changes: 2 additions & 2 deletions tests/src/test/scala/cats/tests/ValidatedTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class ValidatedTests extends CatsSuite {

test("ValidatedNel") {
forAll { (e: String) =>
val manual = Validated.invalid[NonEmptyList[String], Int](NonEmptyList(e))
val manual = Validated.invalid[NonEmptyList[String], Int](NonEmptyList.of(e))
Validated.invalidNel[String, Int](e) should === (manual)
Validated.invalid[String, Int](e).toValidatedNel should === (manual)
}
Expand Down Expand Up @@ -199,7 +199,7 @@ class ValidatedTests extends CatsSuite {
val y: ValidatedNel[String, Boolean] = Validated.invalidNel("error 2")

val z = x.map2(y)((i, b) => if (b) i + 1 else i)
z should === (NonEmptyList("error 1", "error 2").invalid[Int])
z should === (NonEmptyList.of("error 1", "error 2").invalid[Int])
}

test("ensure on Invalid is identity") {
Expand Down