<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 14, 2015, at 7:40 AM, Dave Abrahams via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 14, 2015, at 6:23 AM, Matthew Johnson via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-family: AvenirNext-Regular; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">It is definitely possible to solve this problem for associated types by binding or constraining them. &nbsp;The ML module system has a feature that is roughly analogous to this. &nbsp;</div></div></blockquote><div class=""><br class=""></div>Keep in mind that a language feature like binding/constraining associated types is not a complete solution for real use-cases, so we would still need AnySequence&lt;Element&gt; in the library. &nbsp;Otherwise it would be SequenceType&lt;Generator: SomeGenerator&gt;, which binds a type that you don't actually want to expose.</div></div></div></blockquote></div><br class=""><div class="">With generic typealiases, you could say something like this:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">typealias AnySequence&lt;Element&gt; =</div><div class="">&nbsp; protocol&lt;SequenceType where Generator.Element == Element&gt;</div></blockquote><div class=""><br class=""></div><div class="">However, once we add 'where' requirements to protocols, it seems to me 'Element' really ought to be a direct requirement of SequenceType, like this:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">protocol SequenceType {</div><div class="">&nbsp; typealias Element</div><div class="">&nbsp; typealias Generator: GeneratorType</div><div class="">&nbsp; &nbsp; where Element == Generator.Element</div><div class="">}</div></blockquote><div class=""><br class=""></div><div class="">which would save generic code from having to splatter '.Generator.Element' everywhere, and make unspecialized code more efficient, since the type metadata for Element would be directly available from the SequenceType protocol witness table instead of needing an extra indirection through to its Generator's GeneratorType table.</div><div class=""><br class=""></div><div class="">-Joe</div></body></html>