[swift-evolution] [Proposal] Conditional Conformance on Protocols/Generic Types

Dan Zimmerman daniel.zimmerman at me.com
Sat Jun 4 16:12:16 CDT 2016


Hey,

I was interested in adopting the ability for a type that's generic in some sense (either via generics or via associated types, in the case of protocols) to conform to other protocols conditionally based on its type parameter/associated type. For example:

```
extension CollectionType: Equatable where Generator.Element: Equatable {}

func ==<Collection: CollectionType where Collection.Generator.Element: Equatable>(left: Collection, right: Collection) -> Bool {
  return zip(left, right).reduce(true) { accumulator, tuple in accumulator && (tuple.0 == tuple.1) }
}
```

If this has already been proposed and knocked out/accepted please direct me to the right place.


More information about the swift-evolution mailing list