Mirror.ProductOf instance for Value class #17801
Replies: 7 comments
-
Instead of using value classes why not use opaque types? |
Beta Was this translation helpful? Give feedback.
-
Both are supported, so derivation should be available for both. |
Beta Was this translation helpful? Give feedback.
-
Yes it should be available for both. I was not trying to say otherwise. Opaque types have the guarantee of no overhead, value classes don't because some times there is boxing involved. The way I see it is: you will eventually have to migrate to opaque types why not migrate right now and benefit from no overhead and support for Mirrors? |
Beta Was this translation helpful? Give feedback.
-
This rationale of asking people to migrate all value classes to opaque types could make sense in the end ... Could ... But not sure ... Otherwise value classes would have been removed or at least been deprecated. Anyway, that's not a good strategy to me to ask to migrate all the value classes whereas that's quite easy to have derivation for. |
Beta Was this translation helpful? Give feedback.
-
From Scala 3 Overview
|
Beta Was this translation helpful? Give feedback.
-
Value classes also remain relevant when cross-building for Scala 2 and 3. |
Beta Was this translation helpful? Give feedback.
-
The topic of Mirrors for value classes was discussed today in the Scala 3 Core meeting. At the same time, the team is considering working on the Mirrors/derivation mechanism for the opaque types in the future. We do encourage you to discuss on the existing Pre-SIP for opaque types derivation |
Beta Was this translation helpful? Give feedback.
-
For now, Value classes are not provided
Mirror.ProductOf
instances.Something as below could be used.
Usage:
Beta Was this translation helpful? Give feedback.
All reactions