Skip to content

Add Enum Eq #2552

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

Merged
merged 18 commits into from
May 29, 2017
Merged

Add Enum Eq #2552

merged 18 commits into from
May 29, 2017

Conversation

odersky
Copy link
Contributor

@odersky odersky commented May 28, 2017

Add an Eq instance to every Enum so that they can be compared only to other values of the same type.

// : Eq[C[T1$1, ..., Tn$1], C[T1$2, ..., Tn$2]] = Eq
def eqInstance = {
def append(tdef: TypeDef, str: String) = cpy.TypeDef(tdef)(name = tdef.name ++ str)
val leftParams = derivedTparams.map(append(_, "$1"))
Copy link
Member

Choose a reason for hiding this comment

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

Any reason to not use semantic names here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we could do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On the other hand, maybe it's not worth the hassle. The names literally don't matter.

If all you do with `y` is compare it to other values of type `T`, the program will
typecheck but probably give unexpected results.

Multiversal equaliy is an opt-in way to make universal equality
Copy link

Choose a reason for hiding this comment

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

Typo: equality

The `dotty.DottyPredef` object defines a number of `Eq`
implicits. `dotty.DottyPredef` is a temporary `Predef`-like object.
The contents of this object are by default imported into every
program. Once dotty becomes standard Scala, `DottyPredef` will go away
Copy link

Choose a reason for hiding this comment

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

What's the standard spelling of Dotty? "dotty", "Dotty", context-dependent? When does one capitalize?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, let's settle on capitalizing it

---
layout: doc-page
title: "Named Type Arguments"
---
Copy link

Choose a reason for hiding this comment

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

It would also be great to have a page about implicit function types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Coming up...

@odersky
Copy link
Contributor Author

odersky commented May 29, 2017

@senia-psm Fixing it, thanks!

@felixmulder felixmulder merged commit a570e24 into scala:master May 29, 2017
@smarter smarter mentioned this pull request May 29, 2017
@allanrenucci allanrenucci deleted the add-enum-eq branch December 14, 2017 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants