From 1a1ddb26a89d0531c8e980a2336d32536f8bd132 Mon Sep 17 00:00:00 2001 From: JCranky Date: Thu, 5 Oct 2017 00:24:44 +0200 Subject: [PATCH 1/5] Add ::: to NonEmptyList --- core/src/main/scala/cats/data/NonEmptyList.scala | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/main/scala/cats/data/NonEmptyList.scala b/core/src/main/scala/cats/data/NonEmptyList.scala index 946729b011..4fa96961fa 100644 --- a/core/src/main/scala/cats/data/NonEmptyList.scala +++ b/core/src/main/scala/cats/data/NonEmptyList.scala @@ -99,6 +99,9 @@ final case class NonEmptyList[+A](head: A, tail: List[A]) { def prepend[AA >: A](a: AA): NonEmptyList[AA] = NonEmptyList(a, head :: tail) + def :::[AA >: A](other: NonEmptyList[AA]): NonEmptyList[AA] = + other.concat(this) + /** * Remove elements not matching the predicate * From 852e495b82ba897e493c0aaad325e4bce0fe99cc Mon Sep 17 00:00:00 2001 From: JCranky Date: Thu, 5 Oct 2017 06:38:21 +0200 Subject: [PATCH 2/5] Add ++: to NEV and some doc to ::: in NEL --- core/src/main/scala/cats/data/NonEmptyList.scala | 3 +++ core/src/main/scala/cats/data/NonEmptyVector.scala | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/core/src/main/scala/cats/data/NonEmptyList.scala b/core/src/main/scala/cats/data/NonEmptyList.scala index 4fa96961fa..1a49cc11b6 100644 --- a/core/src/main/scala/cats/data/NonEmptyList.scala +++ b/core/src/main/scala/cats/data/NonEmptyList.scala @@ -99,6 +99,9 @@ final case class NonEmptyList[+A](head: A, tail: List[A]) { def prepend[AA >: A](a: AA): NonEmptyList[AA] = NonEmptyList(a, head :: tail) + /** + * Alias for [[concat]] + */ def :::[AA >: A](other: NonEmptyList[AA]): NonEmptyList[AA] = other.concat(this) diff --git a/core/src/main/scala/cats/data/NonEmptyVector.scala b/core/src/main/scala/cats/data/NonEmptyVector.scala index 0750618411..cccb249312 100644 --- a/core/src/main/scala/cats/data/NonEmptyVector.scala +++ b/core/src/main/scala/cats/data/NonEmptyVector.scala @@ -71,6 +71,11 @@ final class NonEmptyVector[+A] private (val toVector: Vector[A]) extends AnyVal */ def ++[AA >: A](other: Vector[AA]): NonEmptyVector[AA] = concat(other) + /** + * Append this NEV to another NEV, producing a new `NonEmptyVector`. + */ + def ++:[AA >: A](other: NonEmptyVector[AA]): NonEmptyVector[AA] = other.concatNev(this) + /** * Append another `Vector` to this, producing a new `NonEmptyVector`. */ From 76cb9850ba5294f2c289a78e58a1e7305acda5c8 Mon Sep 17 00:00:00 2001 From: JCranky Date: Thu, 5 Oct 2017 12:03:36 +0200 Subject: [PATCH 3/5] Add doctest for NEL.::: and NEV.++: --- core/src/main/scala/cats/data/NonEmptyList.scala | 7 +++++++ core/src/main/scala/cats/data/NonEmptyVector.scala | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/core/src/main/scala/cats/data/NonEmptyList.scala b/core/src/main/scala/cats/data/NonEmptyList.scala index 1a49cc11b6..a3d4f71b63 100644 --- a/core/src/main/scala/cats/data/NonEmptyList.scala +++ b/core/src/main/scala/cats/data/NonEmptyList.scala @@ -101,6 +101,13 @@ final case class NonEmptyList[+A](head: A, tail: List[A]) { /** * Alias for [[concat]] + * + * {{{ + * scala> import cats.data.NonEmptyList + * scala> val nel = NonEmptyList.of(1, 2, 3) + * scala> nel ::: NonEmptyList.of(4, 5) + * res0: cats.data.NonEmptyList[Int] = NonEmptyList(1, 2, 3, 4, 5) + * }}} */ def :::[AA >: A](other: NonEmptyList[AA]): NonEmptyList[AA] = other.concat(this) diff --git a/core/src/main/scala/cats/data/NonEmptyVector.scala b/core/src/main/scala/cats/data/NonEmptyVector.scala index cccb249312..5dbf4f312a 100644 --- a/core/src/main/scala/cats/data/NonEmptyVector.scala +++ b/core/src/main/scala/cats/data/NonEmptyVector.scala @@ -73,6 +73,13 @@ final class NonEmptyVector[+A] private (val toVector: Vector[A]) extends AnyVal /** * Append this NEV to another NEV, producing a new `NonEmptyVector`. + * + * {{{ + * scala> import cats.data.NonEmptyVector + * scala> val nev = NonEmptyVector.of(1, 2, 3) + * scala> nev ++: NonEmptyVector.of(4, 5) + * res0: cats.data.NonEmptyVector[Int] = NonEmptyVector(1, 2, 3, 4, 5) + * }}} */ def ++:[AA >: A](other: NonEmptyVector[AA]): NonEmptyVector[AA] = other.concatNev(this) From 497f4a210da5e657f9a0ca65fbf631504219f5ee Mon Sep 17 00:00:00 2001 From: JCranky Date: Wed, 18 Oct 2017 14:28:16 +0200 Subject: [PATCH 4/5] Use concatNel instead of concat --- core/src/main/scala/cats/data/NonEmptyList.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/scala/cats/data/NonEmptyList.scala b/core/src/main/scala/cats/data/NonEmptyList.scala index a3d4f71b63..e48d507ad1 100644 --- a/core/src/main/scala/cats/data/NonEmptyList.scala +++ b/core/src/main/scala/cats/data/NonEmptyList.scala @@ -110,7 +110,7 @@ final case class NonEmptyList[+A](head: A, tail: List[A]) { * }}} */ def :::[AA >: A](other: NonEmptyList[AA]): NonEmptyList[AA] = - other.concat(this) + other.concatNel(this) /** * Remove elements not matching the predicate From d8b501d9a3fcf6cda9d6798fd1ac06b722a5df2b Mon Sep 17 00:00:00 2001 From: JCranky Date: Tue, 24 Oct 2017 17:50:02 +0200 Subject: [PATCH 5/5] Fix concat reference in scaladoc --- core/src/main/scala/cats/data/NonEmptyList.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/scala/cats/data/NonEmptyList.scala b/core/src/main/scala/cats/data/NonEmptyList.scala index e48d507ad1..81b8edc604 100644 --- a/core/src/main/scala/cats/data/NonEmptyList.scala +++ b/core/src/main/scala/cats/data/NonEmptyList.scala @@ -100,7 +100,7 @@ final case class NonEmptyList[+A](head: A, tail: List[A]) { NonEmptyList(a, head :: tail) /** - * Alias for [[concat]] + * Alias for concat * * {{{ * scala> import cats.data.NonEmptyList