-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Derivation documentation: use inline def derived
so that derives
is employed
#16919
Conversation
@@ -419,7 +419,7 @@ object Eq: | |||
case ((x, y), elem) => check(elem)(x, y) | |||
} | |||
|
|||
inline given derived[T](using m: Mirror.Of[T]): Eq[T] = | |||
inline def derived[T](using m: Mirror.Of[T]): Eq[T] = |
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 believe there is a test case with this example that also needs to be updated.
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.
a cursory search of "given derived" reveals quite a lot of instances, including in the docs/_docs/reference/contextual/derivation-macro.md
document, which is derivation using macro quotes and splices instead of inline match
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 think the macro version of this document should also be updated:
https://github.com/lampepfl/dotty/blob/1a2615b03f7f8507cf5926120beb187cb09c14ac/docs/_docs/reference/contextual/derivation-macro.md?plain=1#L34
I have some sad news to share. The version with
|
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.
There are many more examples of given derived
on both of these documentation pages, with these changes now the content is inconsistent
oops :O, would you like to try and fix the example? |
I tried but failed :( enum Color derives Eq:
case Black
case White
|
I tried and fixed the example: the issue is that because the example also protects against infinite types such as this: scala> case class Stream[+T](t: T, ts: Stream[T]) derives Eq
-- Error: ----------------------------------------------------------------------
1 |case class Stream[+T](t: T, ts: Stream[T]) derives Eq
| ^
| infinite recursive derivation I guess if someone wants to support this case they could modify it to pass down the root instance for reuse |
@bishabosha you seem to know what you're talking about. You're probably much more qualified than me. Feel free to take over this Pull Request. About the infinitely recursive type, it could still be useful, Eq can return false upon first different elements. So there could be utility in that and it would be great if the documentation explained how to implement derivation for types like this. |
I can take over |
Hello @nicolasstucki @bishabosha , are there any news regarding this issue? |
Hey yeah I'll work on this today |
closed in favour of #17414 |
This PR complements the the issue