<div dir="ltr">Totally +1 here.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 20, 2017 at 11:12 PM, Douglas Gregor via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On Mar 11, 2017, at 9:49 PM, Karl Wagner <<a href="mailto:razielim@gmail.com" target="_blank">razielim@gmail.com</a>> wrote:</div><br class="m_2620267345785798761Apple-interchange-newline"><div><div style="word-wrap:break-word">I have a model like this:<div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="Courier">protocol Promise {</font></div><div><font face="Courier"> associatedtype Result</font></div><div><font face="Courier">}</font></div><div><font face="Courier"><br></font></div><div><font face="Courier">protocol Scanner {</font></div><div><font face="Courier"> associatedtype ScanPromise: Promise</font></div><div><font face="Courier"><br></font></div><div><font face="Courier"> func promiseScan<T>(from: Offset, until: (Offset, Item) -> T?) -> ScanPromise // where Result == T?</font></div><div><font face="Courier">}</font></div></blockquote><div><br></div><div>The thing that I’m trying to express is: whichever type implements the associated type ‘ScanPromise’ must be generic, and that parameter must be its result (i.e. something it got as a result of calling the “until” closure).</div><div><br></div><div>Even with SE-0142, this kind of constraint would not be possible. What I would like to write is something like this:</div><div><br></div><div><div><font face="Courier">protocol Promise {</font></div><div><font face="Courier"> associatedtype Result</font></div><div><font face="Courier">}</font></div><div><font face="Courier"><br></font></div><div><font face="Courier">protocol Scanner {</font></div><div><font face="Courier"> associatedtype ScanPromise<T>: Promise // now generic. [SE-0142]: where Result == T</font></div><div><font face="Courier"><br></font></div><div><font face="Courier"> func promiseScan<T>(from: Offset, until: (Offset, Item) -> T?) -> ScanPromise<T></font></div><div><font face="Courier">}</font></div></div><div><br></div><div>Thoughts?</div></div></div></blockquote><br></div><div>Some of us who work on the Swift compiler have talked about this extension to the model before, and we *think* it dodges some of the concerns about introducing more-general higher-rank types in Swift while enabling reasonable use cases like the one you provide. It seems like a reasonable direction.</div><div><br></div><div>Way out of scope for Swift 4 at this point, of course ;)</div><div><br></div><div><span class="m_2620267345785798761Apple-tab-span" style="white-space:pre-wrap">        </span>- Doug</div><div><br></div><br></div><br>______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br></blockquote></div><br></div>