Just to try to draw out something actionable before diving further into alt-designs, do we all agree that the current incarnation of Singleton
as an upper bound should be marked experimental for the 2.13 release, while these alt-designs cook?
Thatās part of SIP23 which was approved (and already used is some projects). Personally, I would rather any changes in this concept are passed through a SIP process, including a deprecation/language flag.
Iām not sure whatās special about 2.13 here, scala.Singleton has existed and has had this behavior since before 2.13.
wow, I did not know this, sorry folks
Or even bolder! Explicit kinds (sneaking them in through a magic context bound?)
def foo[T: Kind[Singleton]](t: T) = ...
I do like the idea of a magic context bounds, itās the closest Iāve seen to Milesā desire for a general purpose elaboration mechanism.
I recant my idea of a caret in the same position as +
/-
and instead give you⦠elaboration bounds
def foo[T ^ Singleton](t: T) = ...
Just as bold, but slightly less magical.
Given how commonly ^
is used for higher-kinded multiplication (a.k.a exponentiation), I like how the intuition works on this.
CPS did that for return types, for type parameters (e.g. @specialized
) itās a prefix.
Iām not sure, if the only way to define an āelaboration boundā is by hardcoding its behavior in the compiler, then the syntax you propose doesnāt seem any better than using a keyword for each hardcoded behavior, and it raises more questions, like whatās Singleton
? Is it a type ? If so, what are the values of this type ? etc.