-
Notifications
You must be signed in to change notification settings - Fork 534
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
Shapeless 2 on Dotty #1043
Comments
As far as I understood, it would not be possible to implement For reference, Why couldn’t we also implement If we can’t implement |
It's totally possible. We even have a plugin to enable using by-name implicit syntax on Scala 2.12 which is replaced by
I don't know about that. The biggest problem for binary compatibility is that Shapeless 2.3 is using a weird encoding of |
That’s good to know. I’m summoning @nicolasstucki to ask whether it is possible or not to express type refinements of the type inline def getLabel[L <: Symbol]: String = compiletime.constValue[L].name
inline val bar = Symbol("bar")
println(getLabel[bar.type]) |
I like us to get off using That's already done in shapeless 3, but that's Scala 3 only so far. I think we should do the same for shapeless 2.4 ... it'll be a breaking change, but I think we have to live with that. |
I guess it’s OK to switch to Typically, I have code like this: implicit def consRecord[L <: Symbol, H, T <: HList](implicit
labelHead: Witness.Aux[L],
jsonSchemaHead: JsonSchema[H],
jsonSchemaTail: DerivedGenericRecord[T]
): DerivedGenericRecord[FieldType[L, H] :: T] = ... I will have to change for the following: implicit def consRecord[L <: String, H, T <: HList](implicit
labelHead: Witness.Aux[L],
jsonSchemaHead: JsonSchema[H],
jsonSchemaTail: DerivedGenericRecord[T]
): DerivedGenericRecord[FieldType[L, H] :: T] = ... But the erased signature will be the same, so this change will be binary compatible. |
I'm not sure about that because |
Oh right, it erases to its bound, so I will have to introduce a separate method. |
Ok, so progress is happening on this finally. So far I've gotten a version of Shapeless 2 compiling on both Scala 2 and 3, but where all macros are dummied out. No idea how well it works after it compiles. One big discussion which needs to be had is what to do with everything that can't be cleanly ported to Scala 3? This is mostly macros that do things Scala 3 macros can't or types not representable in Scala 3. As I can see, there are a bunch of similar macros, which can be grouped and talked about together.
There are also the type quantifiers Shapeless exposes, which can be seen here.
It's clear that none of these can be included in the Scala 3 artifact, but should they still be included in the Scala 2 artifact? My current progress on porting Shapeless 2 to Scala 3 can be found here for anyone interested. |
@Katrix I think we should drop features that we can't port to Scala 3. My reasoning is that Shapeless 2.4 will almost certainly be the last binary breaking release of Shapeless 2, which means that we can't deprecate those features in 2.4 and drop them later. In any case it would be good to deprecate in 2.3 anything we are going to drop in 2.4. I don't think most of these features are particularly important:
What's the problem with those? Existential types? |
@Katrix I agree with @joroKr21 on all points.
Does anyone use these? They date from when shapeless was really just an experiment and they really don't have any practical use. I'm not planning to add anything similar to shapeless 3 and I'd be in favour of dropping them even if they could be ported to Scala 3. |
For those that want to follow along, and provide input and help along the way. Progress to far:
Removals:
Questions:
|
Here are my 2 cents about some of your questions:
It seems that currently there is no convenient syntax for expressing record types, so I would say yes to this proposal.
Since the purpose of Shapeless 2 on Scala 3 is mainly to ease cross-compiling, I don’t think it is a big issue to have worse error messages in Scala 3 because I expect people to cross-compile with Scala 2 and get the better error messages there. However, if it is possible to do the same validation in a macro in Scala 3 as well, I would go for that.
I would copy Shapeless 3’s implementation in Shapeless 2 instead. |
Yes, I think that's a good idea.
Both of these were intended to improve the ergonomics of using singleton types in the pre-SIP23 world ... they should go.
I don't know. I suggest taking it out and seeing what breaks.
All the poly macros should just go with no replacement.
Now that we can assume literal types we should be able come up with some macro-free syntax to replace this, ideally aligned with the
I doubt that many people are using
Copy shapeless 3's. |
Just chiming in here to say I think a shapeless 2 for scala 3 would be very valuable. I understand we might not get 100% source code compatibility, but getting that number as high as possible will really be a help to projects that crossbuild for scala 2, which I expect we will be dealing with for at least several more years. |
For my masters thesis I need to do comparisons against Shapeless, so I might get back to it then, but I don't know how much I'll get to complete then, so would be good to look for someone else. I will say that the majority of the remaining work from what I can see is to minimize Scala 3 bugs and irregularities, where it behaves differently from Scala 2. The library has theoretically been ported, only the tests remain, but those tests might show that something is quite broken currently. |
This is a general meta-issue to aggregate the overall project of getting a version of Shapeless 2 working on Dotty.
Goals
scalaVersion
for any code which exclusively uses the supported constructsNon-Goals
Requirements
Each of these should be split out into a separate issue:
Generic
HList
Coproduct
Comments and opinions very much desired on all of the above!
To be clear, I'm well aware that most of this is covered by out-of-the-box functionality in Dotty (and shapeless 3 is a nice layer on top of that). However, any project which is cross-publishing between Scala 2 and Scala 3 will benefit considerably from this type of functionality. Additionally, cross-publication is a special case of migration, and any project which is using shapeless already will either need something like this, or it will need to recreate this type of functionality on their own for bespoke cross-building (i.e. what Circe had to do).
The text was updated successfully, but these errors were encountered: