export means "trouble" in my dialect of Scala #409
Replies: 4 comments 2 replies
-
I have also run into some hard (for me) to understand corner cases where In case it helps, here are some issues I've filed against scala 3 while trying to write scala3-coulomb
|
Beta Was this translation helpful? Give feedback.
-
Hi Erik, First up, thanks for sharing your issues list. Wow! You clearly are one of the pioneers pushing the bounds of what Scala 3 can do 👏 I might well be catching up, but I had a bit of an "aha" moment this morning. I realized that my earlier statement "it seems like an exported type isn't a transparent alias to the original" isn't how exports were intended to work. They are supposed to be transparent aliases, and oftentimes they do work. Here's an example I fashioned with a "diamond" dependency structure, showing that Scala3 can reconcile exported and imported views onto the same type:
So I now suspect the compiler error I hit above in Coulomb ( Nxt step is to test that hypothesis by reverting to purely importing coulomb without my |
Beta Was this translation helpful? Give feedback.
-
OK, pulling on this Observed behavior in above example is that, by the time we've reached
My question to you Erik is, which is intended? Should the units going into a delta subtraction be dealiased, or not? I think the answer is surely "yes". De-aliasing through So I think the problem sits with WDYT? |
Beta Was this translation helpful? Give feedback.
-
Actually, as I discovered in #410 the different type aliases in the error msg is probably a red herring, real issue is just that cannot subtract seconds from millis without first aligning types. |
Beta Was this translation helpful? Give feedback.
-
I've hit several errors in the last couple of weeks which have hinted at problems introduced by
export
ing types, but Ive finally found a clear-cut example.It concerns
Second
which is originally defined in thecoulomb.units.si
package. It's exported bytime
within coulomb, but I'm similarly exporting it in mybasetypes
package:The problem seems to happen because the intersection of two factors: it seems like an exported type isn't a transparent alias to the original, but a brand new type, And yet somehow, the original Second type gets "captured" somewhere within Coulomb's machinery.
The result is visible below. It is not possible to subtract seconds from milliseconds, because coulomb doesn't recognise that they're derived from the same
Second
substrate type.The line that fails to compile is noisy because I've ascribed explicit types to make it clear
coulomb.units.si.Second
doesn't appear anywhere.Beta Was this translation helpful? Give feedback.
All reactions