-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add ::: to NonEmptyList #1949
Add ::: to NonEmptyList #1949
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1949 +/- ##
==========================================
+ Coverage 96.21% 96.21% +<.01%
==========================================
Files 272 272
Lines 4627 4629 +2
Branches 124 119 -5
==========================================
+ Hits 4452 4454 +2
Misses 175 175
Continue to review full report at Codecov.
|
if you want, you can add a doctest to make the test coverage happy. |
@@ -82,6 +82,9 @@ final case class NonEmptyList[+A](head: A, tail: List[A]) { | |||
def ::[AA >: A](a: AA): NonEmptyList[AA] = | |||
NonEmptyList(a, head :: tail) | |||
|
|||
def :::[AA >: A](other: NonEmptyList[AA]): NonEmptyList[AA] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually to maintain symmetry, can we add ++:
to NonEmptyVector
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure :)
Regarding doctest, where should I look at? I new to the cats codebase. |
Doc test is a test in the Scaladoc right above the method itself :) our build pipeline we automatically check if the result is the same. An example can be found in |
@@ -66,6 +66,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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't these be the other way around? ++
for two NEV
s and ++:
for an NEV
and a Vector
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, I went with this #1838 (comment) - perhaps we should have both for both, since overloading is happening already anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to mimic the API in Vector
and List
. Let's address #1838 first
@LukaJCB thanks for the explanation on doc test, I'll have a look |
Tests added. This doctest thing is really cool, can you point me to somewhere where I can understand better how it works? Thanks! |
Check out sbt-doctest :) |
@LukaJCB thanks! |
In the meanwhile, please let me know if I should do something else here :) |
I guess we can now merge this as well? :) |
* }}} | ||
*/ | ||
def :::[AA >: A](other: NonEmptyList[AA]): NonEmptyList[AA] = | ||
other.concat(this) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we use concatNel here instead? concat is deprecated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
@kailuowang done |
@kailuowang anything else I should do here ? :) |
The build is broken in scala doc generation
Instead of linking it using |
@kailuowang ok, my bad, I was blind and didn't see the build was broken. Fixed :) |
@jcranky no worries at all. i probably should've pointed it out earlier. |
@kailuowang now the build is ok 👍 🗡️ |
It's not obvious to me what the use case is here. |
@tpolecat my main reasoning for this was to keep symmetry with |
(I found myself using |
@tpolecat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, seems fine. 👍
thanks :) |
No description provided.