-
-
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
Make NonEmptyVector a value class. #1204 #1212
Make NonEmptyVector a value class. #1204 #1212
Conversation
…Vector to concatVector. Updates test. Adds additional consistency test.
Current coverage is 89.53% (diff: 100%)@@ master #1212 diff @@
==========================================
Files 234 234
Lines 3144 3143 -1
Methods 3085 3091 +6
Messages 0 0
Branches 57 49 -8
==========================================
+ Hits 2804 2814 +10
+ Misses 340 329 -11
Partials 0 0
|
Hmm, just noticed #1214, which affects this a lot. I wonder is there a nice way to still be a value class and prevent the issue on #1214 at the same time. Maybe turning |
@mikejcurry as far as supporting both this and #1214, I think it shouldn't be a problem as long as we make it no longer a case class (as that issue suggests). I think it would look like Unfortunately, there are still some compiler errors related to value classes. Having said that, this seems like a reasonable change to me that I don't really expect to cause trouble. I'm curious whether @non, @johnynek, or @mpilquist have any thoughts. I feel slightly inclined to use |
Hmmm, so I thought (on scala 2.10), that a value class needed exactly one public val parameter in primary constructor and scala 2.11 private was fine. Which is the bit that concerned me. Will do some research/testing as it could have changed/I could be wrong. |
Ok, cool, looks like I misinterpreted the implications of the value class limitation with regard to vals, and seems like private constructors work fine - did a quick test and seems like it should fit together. I can fold the work for #1214 into this also as this would be a bit deficient without it I think. Might be a few days before I get to it though. |
I don't like the I agree that if you can only have one arg type, I would take |
@johnynek I'm not super happy about the |
@ceedubs @johnynek @peterneyens So, based on feedback have done the following:
I also bumped the version of scalatest by one to M8. Testing that something doesn't compile was falling foul of some bug in scalatest in M7 which was fixed in M8. Bumping the version to M8 allowed that test to be written. I considered bumping further, but that is more involved, as newer versions of scalatest have more invasive changes that would require bumping versions of discipline etc also - and I didn't want to pollute this PR. Let me know what you think. |
Hmmm, didn't build scala js locally, and I didn't think accessing the version would require a callout like that. Not sure whether to remove the test or factor it into a scala 2.11 specific location. Open to ideas. The test is somewhat useful, but the scala 2.10 defect is a bit of a pain. |
…the scala version
Forgot about the The build failure looks like it might be spurious. |
Thanks @mikejcurry! I just restarted the build. Hopefully it works this time. |
👍 excellent. Thanks again! |
} | ||
} | ||
|
||
test("Cannot create a new NonEmptyVector from apply with an empty 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.
test description a bit misleading, can remove the word "empty"
"Cannot create a new NonEmptyVector from apply with 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.
Fair point on the wording. Will rename when I get to a laptop I can work on it from. Hopefully this evening.
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 the perfect use-case for living on the wild side and using the in-browser GitHub editor :D
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.
Yea, that's true - :-). I didn't get a chance to get back to this unfortunately. I'll get to it, and the other comments, by the end of the week all going well.
👍 |
1 similar comment
👍 |
Thanks for merging - I'll follow up on @kailuowang comment - #1212 (comment) separately pretty soon. I just hadn't gotten to it prior to this merge. |
As suggested might be useful in #1204 -
Merging this would make
NonEmptyVector
a value class, which may be useful in some scenarios. It also:Vector
toconcatVector
.++
taking aVector
to+++
Updates scaladoc in some minor places, including turning references to concat and concatVector from
++
and+++
respectively into links to the relevant methods.Not sure about naming, especially
+++
, but figured a PR would be a good place to discuss:(a) The naming,
(b) If this is something we would want to do.