Scala Language Specification specifies syntax of Existential Types as
Type ::= InfixType ExistentialClauses
ExistentialClauses ::= ‘forSome’ ‘{’ ExistentialDcl
{semi ExistentialDcl} ‘}’
ExistentialDcl ::= ‘type’ TypeDcl
| ‘val’ ValDcl
I have seen a lot code use forSome
and type
together, e.g.
List[T] forSome { type T; }
But I have never seen forSome
with val
, is there any sample?