Implement NonEmptyList#Collect#1516
Implement NonEmptyList#Collect#1516kailuowang merged 1 commit intotypelevel:masterfrom xavier-fernandez:NonEmptyCollections_collect
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1516 +/- ##
==========================================
+ Coverage 92.33% 92.33% +<.01%
==========================================
Files 247 247
Lines 3900 3903 +3
Branches 137 139 +2
==========================================
+ Hits 3601 3604 +3
Misses 299 299
Continue to review full report at Codecov.
|
|
I'm weakly -1 on adding methods which are identical to doing Methods that preserve nonemptiness are more interesting to me. |
|
What about returning: |
|
@xavier-fernandez, unless I am missing something, a |
|
I should close the PR? |
|
The main arguments that I can think of for having the |
|
On the other hand, |
|
Okay. On this argument I'm +1 on NonEmptyList.collect but not
NonEmptyVector.
…On Thu, Jan 5, 2017 at 23:58 Xavier Fernández Salas < ***@***.***> wrote:
NonEmptyList.collect will have a better performance than toList.collect...
On the other hand,NonEmptyVector.collect will not yield any performance
improvement.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1516 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAEJdhyLQCQk9tS8ORePNXVRx52xQIFvks5rPhBKgaJpZM4Lbksu>
.
|
|
If |
|
I don't think so. Otherwise we'll have some other class justifying why we
should have yet another method.
Frankly, if consistency is the main driver I suggest we go back to only
adding methods if they preserve non-emptiness.
…On Sat, Jan 7, 2017 at 00:48 Xavier Fernández Salas < ***@***.***> wrote:
If NonEmptyList is having a collect method, it would not be better that
NonEmptyVector too, for consistency?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1516 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAEJdvMOcd92tju5KLvjpL_hc-crW2fRks5rP21igaJpZM4Lbksu>
.
|
NonEmptyVector and NonEmptyList|
Modified the PR so the |
| else head :: ftail | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
Should we say "Builds a new List ..." ?
| * res0: scala.collection.immutable.List[Int] = List(1, 2) | ||
| * scala> nel.collect { | ||
| * case v if v % 2 == 0 => "even" | ||
| * case _ => "odd" |
There was a problem hiding this comment.
I think this should be :
/**
* ...
* scala> nel.collect {
* | case v if v % 2 == 0 => "even"
* | case _ => "odd"
* | }
* ...
*/for the doctest to be generated correctly.
|
@peterneyens amend done :) |
|
👍 |
|
You need to use exactly after a Right now the generated doctest is property("example at line 203: nel.collect { case v if v < 3 => v }") = org.scalacheck.Prop.secure {
sbtDoctestTypeEquals(nel.collect { case v if v < 3 => v })((nel.collect { case v if v < 3 => v }): scala.collection.immutable.List[Int])
val actual = sbtDoctestReplString(nel.collect { case v if v < 3 => v })
val expected = "List(1, 2)"
(actual == expected) :| s"'$actual' is not equal to '$expected'"
}So the last "odd" and "even" test is not checked. If you change it to /**
* scala> nel.collect {
* | case v if v % 2 == 0 => "even"
* | case _ => "odd"
* | }
*/It will include this one as well : property("example at line 205: nel.collect { ...") = org.scalacheck.Prop.secure {
sbtDoctestTypeEquals(nel.collect {
case v if v % 2 == 0 => "even"
case _ => "odd"
})((nel.collect {
case v if v % 2 == 0 => "even"
case _ => "odd"
}): scala.collection.immutable.List[Int])
val actual = sbtDoctestReplString(nel.collect {
case v if v % 2 == 0 => "even"
case _ => "odd"
})
val expected = "List(odd, even, odd, even, odd)"
(actual == expected) :| s"'$actual' is not equal to '$expected'"
}It would be handy if |
|
@peterneyens will fix tomorrow morning, thank you :) |
|
Did an ammend fixing the DocTest generation :) |
peterneyens
left a comment
There was a problem hiding this comment.
Thanks for the doctest changes.
|
👍 merging with 2 sign-offs. |
NonEmptyVectorandNonEmptyList.