So, just can't understand why does this compiles?
type <=[B, A] = A => B
type F[A] = Double <= A //why our alias <= is allowed here?
What is the syntax rule of forming type aliases which allows constructions like these? Can we free play only with the order => here like in this case?
CodePudding user response:
There is a very simple rule that every type A B C is the same as B[A, C]. Evidently this only works for types with 2 type parameters.
CodePudding user response:
I could not find the definition of =>
Yeah, it is embedded in the compiler implementation / language specification.
But, as you just show, it is quite easy to reimplement in on userland; it would look like this:
type =>[ A, B] = Function1[A, B]
how Scala compiler parse an alias expression like sequence of types Type1 Type2 Type3
The language specs say that it supports infix types, so things like: A OP B are equivalent to OP[A, B]
