<div dir="ltr">I once put together a sketch for a proposal for GADTs. I wouldn't recommend it be submitted for review today (or ever, really), but it's there if anyone is interested.<div><br></div><div><a href="https://github.com/austinzheng/swift-evolution/blob/az-gadt/proposals/XXXX-enums-as-gadts.md">https://github.com/austinzheng/swift-evolution/blob/az-gadt/proposals/XXXX-enums-as-gadts.md</a><br></div><div><br></div><div>Best,</div><div>Austin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 24, 2017 at 3:24 PM, Jaden Geller 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"><div><div class="h5"><br><div><blockquote type="cite"><div>On Apr 24, 2017, at 3:21 PM, Kevin Nattinger <<a href="mailto:swift@nattinger.net" target="_blank">swift@nattinger.net</a>> wrote:</div><br class="m_8959543573631076583Apple-interchange-newline"><div><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On Apr 24, 2017, at 3:16 PM, Jaden Geller <<a href="mailto:jaden.geller@gmail.com" target="_blank">jaden.geller@gmail.com</a>> wrote:</div><br class="m_8959543573631076583Apple-interchange-newline"><div><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On Apr 24, 2017, at 2:38 PM, Kevin Nattinger <<a href="mailto:swift@nattinger.net" target="_blank">swift@nattinger.net</a>> wrote:</div><br class="m_8959543573631076583Apple-interchange-newline"><div><div style="word-wrap:break-word"><div><blockquote type="cite"><div><div dir="auto"><div><br></div><div>How can I improve your understanding?</div><br></div></div></blockquote></div><div><br></div>Given the enum I was using earlier:<div><br><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2">enum</span><span style="font-variant-ligatures:no-common-ligatures"> Thing {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2">case</span><span style="font-variant-ligatures:no-common-ligatures"> thingOne<T>(T)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2">case</span><span style="font-variant-ligatures:no-common-ligatures"> thingTwo<T>(T)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">}</span></div></div><div><br></div><div>- Write a function that takes a <span style="font-family:Menlo;font-size:11px">thingOne<String> </span>or<span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px">thingTwo<Int> </span>but nothing else.</div></div></div></div></blockquote><div><br></div><div>This isn’t possible since generic types introduced on cases are erased in the type of `Thing`.</div><div><br></div><div>We can actually already achieve what you want by moving the generics onto the type itself, and this is already possible in Swift! No new features are necessary.</div><div><br></div><div>```</div><div><div style="margin:0px 0px 0px 31.5px;line-height:normal;font-family:Monaco;font-size:11px"><span style="color:rgb(201,0,164)">enum</span> Thing<span style="color:rgb(200,0,164)"><</span>T1, T2<span style="color:rgb(200,0,164)">></span> {</div><div style="margin:0px 0px 0px 63px;line-height:normal;font-family:Monaco;font-size:11px"> <span style="color:rgb(200,0,164)">case</span> thingOne(T1)</div><div style="margin:0px 0px 0px 63px;line-height:normal;font-family:Monaco;font-size:11px"> <span style="color:rgb(200,0,164)">case</span> thingTwo(T2)</div><div style="margin:0px 0px 0px 31.5px;line-height:normal;font-family:Monaco;font-size:11px">}</div><div style="margin:0px 0px 0px 31.5px;line-height:normal;font-family:Monaco;min-height:17px;font-size:11px"><br></div><div style="margin:0px 0px 0px 31.5px;line-height:normal;font-family:Monaco;font-size:11px"><span style="color:rgb(201,0,164)">func</span> test(_ x: Thing<span style="color:rgb(200,0,164)"><</span><span style="color:rgb(121,14,173)">String</span>, <span style="color:rgb(121,14,173)">Int</span><span style="color:rgb(200,0,164)">></span>) {</div><div style="margin:0px 0px 0px 63px;line-height:normal;font-family:Monaco;font-size:11px"> <span style="color:rgb(200,0,164)">switch</span> x {</div><div style="margin:0px 0px 0px 63px;line-height:normal;font-family:Monaco;font-size:11px"> <span style="color:rgb(200,0,164)">case</span> <span style="color:rgb(200,0,164)">.</span>thingOne(<span style="color:rgb(201,0,164)">let</span> s):</div><div style="margin:0px 0px 0px 94.6px;line-height:normal;font-family:Monaco;color:rgb(223,0,2);font-size:11px"><span> </span><span style="color:rgb(69,0,132)">print</span><span>(</span>"The string has value \(s)!"<span>)</span></div><div style="margin:0px 0px 0px 63px;line-height:normal;font-family:Monaco;font-size:11px"> <span style="color:rgb(200,0,164)">case</span> <span style="color:rgb(200,0,164)">.</span>thingTwo(<span style="color:rgb(201,0,164)">let</span> i):</div><div style="margin:0px 0px 0px 94.6px;line-height:normal;font-family:Monaco;color:rgb(223,0,2);font-size:11px"><span> </span><span style="color:rgb(69,0,132)">print</span><span>(</span>"The int has value \(i)!"<span>)</span></div><div style="margin:0px 0px 0px 63px;line-height:normal;font-family:Monaco;font-size:11px"> }</div><div style="margin:0px 0px 0px 31.5px;line-height:normal;font-family:Monaco;font-size:11px">}</div></div><div>```</div></div></div></div></blockquote><div><br></div>Yes, that was almost exactly my original example. My understanding of the proposal is that it will remove that capability, which I find completely unacceptable.</div><div><br></div></div></div></blockquote><br></div></div></div><div>Hi Kevin,</div><div><br></div><div>If that is what is being proposed, I agree that that is entirely unacceptable. I however did not understand the proposal to be removing that capability, but instead I understood that it was simply adding another. That is, `Thing<T1, T2>` would *still* be accepted. This feature is entirely additive.</div><div><br></div><div>It would be great if the original proposal author could confirm this.</div><div><br></div><div>Thanks,</div><div>Jaden Geller</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>