<div dir="ltr">Sorry, I&#39;m confused. The following works:<div><br></div><div>```</div><div><p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">protocol</span><span style="font-variant-ligatures:no-common-ligatures"> Promise {</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(186,45,162)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">  </span><span style="font-variant-ligatures:no-common-ligatures">associatedtype</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)"> Result</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">}</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">protocol</span><span style="font-variant-ligatures:no-common-ligatures"> Scanner {</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">  </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">associatedtype</span><span style="font-variant-ligatures:no-common-ligatures"> ScannerPromise : Promise</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">  </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">func</span><span style="font-variant-ligatures:no-common-ligatures"> frobnicate&lt;T&gt;(</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">_</span><span style="font-variant-ligatures:no-common-ligatures">: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">T</span><span style="font-variant-ligatures:no-common-ligatures">) -&gt; ScannerPromise</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">where</span><span style="font-variant-ligatures:no-common-ligatures"> ScannerPromise.Result == </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">T</span></p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">}</span></p></div><div>```</div><div><br></div><div>Why does it matter if `ScannerPromise` is generic or not?</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 11, 2017 at 11:55 PM, Karl Wagner via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</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"><div><div class="h5"><br><div><blockquote type="cite"><div>On 12 Mar 2017, at 06:51, Austin Zheng &lt;<a href="mailto:austinzheng@gmail.com" target="_blank">austinzheng@gmail.com</a>&gt; wrote:</div><br class="m_384998952098754277Apple-interchange-newline"><div><div style="word-wrap:break-word">I think you want higher-kinded types. <a href="https://github.com/apple/swift/blob/master/docs/GenericsManifesto.md#higher-kinded-types" target="_blank">https://github.com/<wbr>apple/swift/blob/master/docs/<wbr>GenericsManifesto.md#higher-<wbr>kinded-types</a><div><br></div><div>Best,</div><div>Austin</div><div><br><div><blockquote type="cite"><div>On Mar 11, 2017, at 9:49 PM, Karl Wagner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_384998952098754277Apple-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&lt;T&gt;(from: Offset, until: (Offset, Item) -&gt; T?) -&gt; 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&lt;T&gt;: Promise // now generic. [SE-0142]: where Result == T</font></div><div><font face="Courier"><br></font></div><div><font face="Courier">    func promiseScan&lt;T&gt;(from: Offset, until: (Offset, Item) -&gt; T?) -&gt; ScanPromise&lt;T&gt;</font></div><div><font face="Courier">}</font></div></div><div><br></div><div>Thoughts?</div><div><br></div><div>- Karl</div></div>______________________________<wbr>_________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br></div></blockquote></div><br></div></div></div></blockquote></div><br><div><br></div></div></div><div>Not necessarily. Higher-kinded types (IIUC) are per-instance - e.g. every instance of a Collection could have a unique type of Index.</div><div><br></div><div>I want to constrain a return value, whose type is an associated type, based on a generic parameter to the function. SE-0142 only allows constraining entire associated types, and allows no interaction with per-function generic parameters.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>- Karl</div></font></span></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></div>