Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Enum typeclass #3458

Merged
merged 15 commits into from
Jul 6, 2020
Merged

Enum typeclass #3458

merged 15 commits into from
Jul 6, 2020

Conversation

yilinwei
Copy link
Contributor

@yilinwei yilinwei commented Jun 6, 2020

Add the Enum typeclass #2342 .

A few comments:

  • There are some instances in UpperBounded and LowerBounded companion objects; should these be deleted?
  • Should the partialOrder be the same field as the order just with the bound overridden?

Copy link
Contributor

@travisbrown travisbrown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are breaking changes here, but I think they can be avoided without changing the core intent, and I like this addition.

I have one general question (in addition to one specific one about the members method): what do you think about using something like Enumerable instead of Enum? I think reusing the Haskell terminology here might not be the right thing to do, given all the different things "enum" means in Scala, Dotty, and Java.

partialPrevious(a).getOrElse(maxBound)

/** Enumerate the members in ascending order. */
def members: List[A] = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this maybe be an Iterable or LazyList / Stream? Having a generic method that returns all members as a list in a context where instances will often be for types like Int seems not really ideal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree! I toyed around with Iterable, but didn't like the idea because it's not pure iirc, and the idea of having an impure return type irked me. I don't have a strong preference on either lazy types but I think a NonEmptyLazyList sounds good? I can then add membersAscending/membersDescending on the LowerBounded and UpperBounded Enum types.

@travisbrown
Copy link
Contributor

@yilinwei Also, to answer your first question: the instances will need to go in all of the type class roots (see the discussion here), and since this is a rare change that adds new type class roots, it will be a little more complicated than usual. I'm happy to take a closer look at that part once the bincompat issues are resolved, if that works for you.

@yilinwei
Copy link
Contributor Author

yilinwei commented Jun 8, 2020

@travisbrown

Thanks for looking at this!

I thought I had ran mima but evidently not correctly. I'll fix the mima issues and ask if I have any particular questions.

Regarding the naming change, I think it makes sense; even more so because we've split it up into Next/Previous.

@travisbrown travisbrown modified the milestones: 2.2.0-M3, 2.2.0 Jun 12, 2020
@yilinwei yilinwei force-pushed the master branch 4 times, most recently from 821e52e to 5b3695b Compare June 25, 2020 16:16
@yilinwei yilinwei force-pushed the master branch 3 times, most recently from 127925c to 6081197 Compare June 25, 2020 18:28
@codecov-commenter
Copy link

codecov-commenter commented Jun 25, 2020

Codecov Report

Merging #3458 into master will decrease coverage by 0.20%.
The diff coverage is 80.88%.

@@            Coverage Diff             @@
##           master    #3458      +/-   ##
==========================================
- Coverage   91.77%   91.56%   -0.21%     
==========================================
  Files         383      386       +3     
  Lines        8400     8466      +66     
  Branches      208      236      +28     
==========================================
+ Hits         7709     7752      +43     
- Misses        691      714      +23     

@yilinwei
Copy link
Contributor Author

yilinwei commented Jun 25, 2020

@travisbrown I've fixed the mima issues and addressed the comments; I seem to be having some dotty issues in the CI.

EDIT.

CI issues were fixed with a clear of the cache.

@travisbrown travisbrown self-requested a review July 5, 2020 06:14
Copy link
Contributor

@travisbrown travisbrown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, thanks!

@travisbrown travisbrown modified the milestones: 2.2.0, 2.2.0-RC1 Jul 5, 2020
@travisbrown travisbrown merged commit 0f22151 into typelevel:master Jul 6, 2020
@isomarcte isomarcte mentioned this pull request Nov 30, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants