SLS specifies syntax of type parameter clause as
TypeParamClause ::= ‘[’ VariantTypeParam {‘,’ VariantTypeParam} ‘]’
FunTypeParamClause::= ‘[’ TypeParam {‘,’ TypeParam} ‘]’
VariantTypeParam ::= {Annotation} [‘+’ | ‘-’] TypeParam
TypeParam ::= (id | ‘_’) [TypeParamClause] [‘>:’ Type] [‘<:’ Type] {‘<%’ Type} {‘:’ Type} {‘<%’ Type} {‘<%’ Type}
where we see >:, <:, <%, <%, : as allowed reserved names in type parameter clause. Is there a way we could use generalised type constraint symbolic names <:<, =:= in the type parameter clause such that
def f[T =:= 42] = ???
would expand to
def f[T](implicit ev: T =:= 42) = ???
similar to how context bound
def f[T: Numeric] = ???
expands to
def f[T](implicit ev: Numeric[T]) = ???
In 2.13 (which supports singleton types if you are curious about constraining on singletons) you can do things like:
So, yes, it seems possible. You just have to use kind projectors to apply second parameter.
With
<:<it should be the same story: