I suggest the following (minor(?)) extension of typealias capabilities:
typealias ExampleAlias = CollectionType where Generator.Element : Equatable, Index : SignedIntegerType
Rationale:
- Lengthy constraints in generic functions:
func foo<T: CollectionType where T.Generator.Element : Equatable, T.Index : SignedIntegerType>(a a: T, b: T)
This is really disturbing when reading source code. One could argue that it's actually good because it describes the function, but then:
- it allows to abstract constraints to reuse them in code
According to @jckarter it has been covered in the generics manifesto in Swift Evolution, but I couldn't find exactly same thing.
Indeed a similar idea has been proposed but with one significant difference - contributors suggested constraints of non-protocol type, which is not even supported generic constraints in general, yet.
e.g.
func foo<T: CollectionType where T.Generator.Element : Equatable, T.Index : Int>(a a: T, b: T)
will fail to compile