简体   繁体   中英

Where is synthetic sugar for generics with two type parameters (ie. that F[A,B] is equal to A F B) documented?

I'm learning Scala and I found out that if I have class:

class Foo[A, B]

Then I can start refering to it as A Foo B instead of Foo[A,B] like this:

var a: Int Foo Double = new (Int Foo Double)

I found out about it when learning about <:< class, but no one mentions how is this possible to write it down like that and I can't find any documentation regarding this. Where can I find things like this documented?

I've seen question about instances of synthetic sugar and it contains my finding, but it's also only a finding. I'd like to know where in Scala documentation can I find the source.

Mentioned question: What are all the instances of syntactic sugar in Scala?

You're looking for Infix Types , from the SLS 3.2.8 :

An infix type T1 op T2 consists of an infix operator op which gets applied to two type operands T1 and T2 . The type is equivalent to the type application op[T1, T2] . The infix operator op may be an arbitrary identifier.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM