I see. You&#39;re not suggesting magic.<br><br>The problem stands that the design of Equatable explicitly encourages the distinction between identity and equality (it even says: &quot;equality is separate from identity&quot;). It follows that we should *not* provide a default implementation that forwards one to the other; if someone determines that this is right for their particular class, then they can trivially write it themselves.<br><br>This goes back to the very high bar for inclusion of something in the standard library. An additional protocol like this needs to hold its own weight, encourage rather than discourage patterns that we aim to promote, help avoid rather than promote misuse, be commonly useful, and be difficult to write on one&#39;s own--among other criteria outlined by Ben Cohen. For many of these criteria, I think your proposed protocol does not pass the bar.<br><br><div class="gmail_quote"><div dir="ltr">On Fri, May 5, 2017 at 00:06 Charlie Monroe &lt;<a href="mailto:charlie@charliemonroe.net">charlie@charliemonroe.net</a>&gt; wrote:<br></div><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><blockquote type="cite"><div>On May 5, 2017, at 6:58 AM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="m_-4999436824520193668Apple-interchange-newline"><div>As the documentation for Equatable discusses, the goal is to distinguish &quot;equality&quot; (==) from &quot;identity&quot; (===). If I understand it correctly, the goal is to *discourage* mixing the two concepts.<br><br>Moreover, while writing a memberwise comparison is tedious and writing a memberwise hash is even error-prone, writing &quot;return lhs === rhs&quot; is both straightforward and impossible to mess up, so having special magic for that use case is much harder to justify.<br></div></blockquote><div><br></div></div></div><div style="word-wrap:break-word"><div><div>There doesn&#39;t need to be any magic - why would there need to be?</div><div><br></div><div>public protocol PointerEquatable: AnyObject, Equatable, Hashable {</div><span class="m_-4999436824520193668Apple-tab-span" style="white-space:pre-wrap">        </span><br><span class="m_-4999436824520193668Apple-tab-span" style="white-space:pre-wrap">        </span>public static func ==(lhs: Self, rhs: Self) -&gt; Bool {<br><span class="m_-4999436824520193668Apple-tab-span" style="white-space:pre-wrap">                </span>return lhs === rhs<br><span class="m_-4999436824520193668Apple-tab-span" style="white-space:pre-wrap">        </span>}<br><span class="m_-4999436824520193668Apple-tab-span" style="white-space:pre-wrap">        </span><br><span class="m_-4999436824520193668Apple-tab-span" style="white-space:pre-wrap">        </span>public var hashValue: Int {<br><span class="m_-4999436824520193668Apple-tab-span" style="white-space:pre-wrap">                </span>return ObjectIdentifier(self).hashValue<br><span class="m_-4999436824520193668Apple-tab-span" style="white-space:pre-wrap">        </span>}<br><span class="m_-4999436824520193668Apple-tab-span" style="white-space:pre-wrap">        </span><br>}</div><div><br></div><div>I&#39;m not saying it&#39;s super hard but while we&#39;re at it, we might as well include something like this in case identity is enough for equality, in such case</div><div><br></div><div>class Foo: PointerEquatable { }</div><div><br></div><div>is enough for the class to be hashable and equatable. It&#39;s all opt-in, there&#39;s no magic - I don&#39;t quite see the downside to it.</div></div><div style="word-wrap:break-word"><div><br></div><div><br><blockquote type="cite"><div><div class="gmail_quote"><div dir="ltr">On Thu, May 4, 2017 at 23:45 Charlie Monroe via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">I&#39;m also leaning towards this being opt-in and the generation could be triggered by having AutoEquatable and AutoHashable protocols.<div><br></div><div>Any chance for this proposal to be extended by adding &quot;PointerEquatable&quot; for classes? In many cases, pointer equality is just enough and having the class equatable by pointer allows e.g. better array inter-op (e.g. removing an object doesn&#39;t require getting an index first)...</div></div><div style="word-wrap:break-word"><div><br><div><br></div><div><br><div><blockquote type="cite"><div>On May 4, 2017, at 10:37 PM, Tony Allevato via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-4999436824520193668m_-2449579574363835825Apple-interchange-newline"><div><div dir="ltr"><div>Hi all,</div><div><br></div>A conversation on Twitter last night brought up some interest in this feature and I was encouraged to revive this proposal.<div><br></div><div>Jordan Rose <a href="https://twitter.com/UINT_MIN/status/859922619578986496" target="_blank">mentioned</a> on Twitter that it could possibly make it in by the Swift 4 deadline if others contributed—I have a WIP branch (albeit not currently working because I rebased after a couple months of it being idle) that does the work for enums but I got stuck on the mutually recursive cases. If this got approved, I&#39;d love to collaborate with other interested folks to finish up the implementation.</div><div><br></div><div>Link: <a href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad" target="_blank">https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad</a></div><div><br></div><div><br></div><div><h1 style="box-sizing:border-box;margin:0px 0px 16px;line-height:1.25;padding-bottom:0.3em;border-bottom:1px solid rgb(234,236,239);color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;">Deriving<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:inherit;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Equatable</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>and<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:inherit;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Hashable</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>for value types</h1><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><li style="box-sizing:border-box">Proposal:<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><a href="https://github.com/apple/swift-evolution/blob/master/proposals/NNNN-name.md" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none" target="_blank">SE-0000</a></li><li style="box-sizing:border-box;margin-top:0.25em">Author(s):<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><a href="https://github.com/allevato" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none" target="_blank">Tony Allevato</a></li><li style="box-sizing:border-box;margin-top:0.25em">Status:<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><span style="box-sizing:border-box;font-weight:600"><a href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#rationale" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none" target="_blank">Awaiting review</a></span></li><li style="box-sizing:border-box;margin-top:0.25em">Review manager: TBD</li></ul><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom:1px solid rgb(234,236,239);color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_-4999436824520193668m_-2449579574363835825inbox-inbox-user-content-introduction" class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#introduction" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Introduction</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">Value types are prevalent throughout the Swift language, and we encourage developers to think in those terms when writing their own types. Frequently, developers have to write large amounts of boilerplate code to support equatability and hashability of value types. This proposal offers a way for the compiler to automatically derive conformance to<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Equatable</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>and<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Hashable</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>to reduce this boilerplate, in a subset of scenarios where generating the correct implementation is known to be possible.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">Swift-evolution thread:<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><a href="http://thread.gmane.org/gmane.comp.lang.swift.evolution/8919" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none" target="_blank">Universal Equatability, Hashability, and Comparability</a></p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom:1px solid rgb(234,236,239);color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_-4999436824520193668m_-2449579574363835825inbox-inbox-user-content-motivation" class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#motivation" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Motivation</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">Building robust value types in Swift can involve writing significant boilerplate code to support hashability and equatability. Equality is pervasive across many value types, and for each one users must implement the<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">==</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>operator such that it performs a fairly rote memberwise equality test. As an example, an equality test for a struct looks fairly uninteresting:</p><div class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-highlight m_-4999436824520193668m_-2449579574363835825inbox-inbox-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal"><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">struct</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Foo</span>: <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-e" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Equatable</span> </span>{
  <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">static</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">func</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">==</span> (<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">lhs</span></span>: Foo, <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">rhs</span></span>: Foo) <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">-&gt;</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Bool</span> {
    <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> lhs.<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property1</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> rhs.<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property1</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">&amp;&amp;</span>
           lhs.<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property2</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> rhs.<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property2</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">&amp;&amp;</span>
           lhs.<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property3</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> rhs.<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property3</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">&amp;&amp;</span>
           <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">...</span>
  }
}</pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">What&#39;s worse is that this operator must be updated if any properties are added, removed, or changed, and since it must be manually written, it&#39;s possible to get it wrong, either by omission or typographical error.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">Likewise, hashability is necessary when one wishes to store a value type in a<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Set</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>or use one as a multi-valued<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Dictionary</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>key. Writing high-quality, well-distributed hash functions is not trivial so developers may not put a great deal of thought into them – especially as the number of properties increases – not realizing that their performance could potentially suffer as a result. And as with equality, writing it manually means there is the potential to get it wrong.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">In particular, the code that must be written to implement equality for enums is quite verbose:</p><div class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-highlight m_-4999436824520193668m_-2449579574363835825inbox-inbox-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal"><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Token</span>: <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-e" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Equatable</span> </span>{
  <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">string</span>(<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span>)
  <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">number</span>(<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Int</span>)
  <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">lparen</span>
  <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">rparen</span>
  
  <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">static</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">func</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">==</span> (<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">lhs</span></span>: Token, <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">rhs</span></span>: Token) <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">-&gt;</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Bool</span> {
    <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">switch</span> (lhs, rhs) {
    <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> (.<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">string</span>(<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> lhsString), .<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">string</span>(<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> rhsString))<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
      <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> lhsString <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> rhsString
    <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> (.<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">number</span>(<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> lhsNumber), .<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">number</span>(<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> lhsNumber))<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
      <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> lhsNumber <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> rhsNumber
    <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> (.<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">lparen</span>, .<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">lparen</span>), (.<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">rparen</span>, .<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">rparen</span>)<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
      <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">true</span>
    <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">default</span><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
      <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">false</span>
    }
  }
}</pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">Crafting a high-quality hash function for this enum would be similarly inconvenient to write.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">Swift already derives<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Equatable</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>and<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Hashable</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>conformance for a small subset of enums: those for which the cases have no associated values (including enums with raw types). Two instances of such an enum are equal if they are the same case, and an instance&#39;s hash value is its ordinal:</p><div class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-highlight m_-4999436824520193668m_-2449579574363835825inbox-inbox-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal"><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Foo</span>  {
  <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">zero</span>, <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">one</span>, <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">two</span>
}

<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> x <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> (Foo.<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">one</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> Foo.<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">two</span>)  <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c" style="box-sizing:border-box">//</span> evaluates to false</span>
<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> y <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> Foo.<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">one</span>.<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">hashValue</span>     <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c" style="box-sizing:border-box">//</span> evaluates to 1</span></pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">Likewise, conformance to<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">RawRepresentable</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>is automatically derived for enums with a raw type. Since there is precedent for derived conformances in Swift, we propose extending this support to more value types.</p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom:1px solid rgb(234,236,239);color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_-4999436824520193668m_-2449579574363835825inbox-inbox-user-content-proposed-solution" class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#proposed-solution" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Proposed solution</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">In general, we propose that value types derive conformance to<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Equatable</code>/<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Hashable</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>if all of its members are<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Equatable</code>/<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Hashable</code>. We describe the specific conditions under which these conformances are derived below, followed by the details of how the conformance requirements are implemented.</p><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_-4999436824520193668m_-2449579574363835825inbox-inbox-user-content-protocol-derivability-conditions" class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#protocol-derivability-conditions" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Protocol derivability conditions</h3><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">For brevity, let<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>represent either the protocol<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Equatable</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>or<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Hashable</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>in the descriptions below.</p><h4 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:16px;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_-4999436824520193668m_-2449579574363835825inbox-inbox-user-content-derived-conformances-for-enums" class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#derived-conformances-for-enums" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Derived conformances for<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:inherit;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">enum</code>s</h4><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">For an<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">enum</code>, derivability of<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>is based on the conformances of its cases&#39; associated values. Computed properties are not considered.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">The following rules determine whether conformance to<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>can be derived for an<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">enum</code>:</p><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><li style="box-sizing:border-box"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">An<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">enum</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>with no cases does not derive conformance to<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code>, since it is not possible to create instances of such types.</p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">An<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">enum</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>with one or more cases derives conformance to<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>if all of the associated values of all of its cases conform to<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>(either explicitly or derived).</p></li></ul><h4 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:16px;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_-4999436824520193668m_-2449579574363835825inbox-inbox-user-content-derived-conformances-for-structs" class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#derived-conformances-for-structs" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Derived conformances for<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:inherit;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">struct</code>s</h4><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">For a<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">struct</code>, derivability of<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>is based on the conformances of its stored instance properties<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">only</em>. Neither static properties nor computed instance properties (those with custom getters) are considered.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">The following rules determine whether conformance to<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>can be derived for a<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">struct</code>:</p><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><li style="box-sizing:border-box"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">A<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">struct</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>with<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">no</em><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>stored properties does<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">not</em><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>derive conformance to<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code>. (Even though it is vacuously true that all instances of a<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">struct</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>with no stored properties could be considered equal and hash to the same value, the reality is that such<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">struct</code>s are more often used for grouping/nesting of other entities and not for their singular value, and we don&#39;t consider it worthwhile to generate extra code in this case.)</p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">A<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">struct</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>with one or more stored properties derives conformance to<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>if all if the types of all of its stored properties conform to<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>(either explicitly or derived).</p></li></ul><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_-4999436824520193668m_-2449579574363835825inbox-inbox-user-content-considerations-for-recursive-types" class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#considerations-for-recursive-types" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Considerations for recursive types</h3><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">For brevity in the discussion below, the term<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">members</em><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>refers only to those members that are checked for deriving conformances:<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">stored properties</em><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>for<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">struct</code>s and<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">associated values</em><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>for<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">enum</code>s.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">Recursive value types require a bit more care when determining whether a conformance can be derived. Consider the following<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">enum</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>with an<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">indirect</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>case:</p><div class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-highlight m_-4999436824520193668m_-2449579574363835825inbox-inbox-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal"><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">TreeNode</span> {
  <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">empty</span>
  <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">leaf</span>(<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">value</span></span>: <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Int</span>)
  <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">internal</span>(<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">left</span></span>: TreeNode, <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">right</span></span>: TreeNode)
}</pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">When examining the<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">internal</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>case, an application of the rules above implies that &quot;<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">TreeNode</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>derives<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>if<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">TreeNode</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>conforms to<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code>&quot;—a recursive condition. In this situation, we note that any instance of this type—or of any recursive type—forms a finite tree structure because the recursion must be terminated eventually by using one of the other base cases. Therefore, without changing the outcome,<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><span style="box-sizing:border-box;font-weight:600">we can assume for the purposes of determining whether<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">T</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>derives<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>that any members of type<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">T</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>already conform to<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code>.</span><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>If any members of different types prohibit deriving<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code>, then we know that the whole type cannot derive it; likewise, if all of the other members permit deriving<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code>, then we know that<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">T</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>can derive it by recursively applying the derived operation.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">This property can be extended to<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">mutually</em><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>recursive types as well. Consider this contrived example:</p><div class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-highlight m_-4999436824520193668m_-2449579574363835825inbox-inbox-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal"><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">A</span> {
  <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">value</span>(<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Int</span>)
  <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">b</span>(B)
}

<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">B</span> {
  <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">value</span>(<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span>)
  <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">c</span>(C)
}

<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">C</span> {
  <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">value</span>(<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Double</span>)
  <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">a</span>(A)
}</pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">The rules state that—ignoring the trivial cases—&quot;<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">A</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>derives<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>if<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">B</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>conforms to<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code>,&quot; and &quot;<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">B</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>derives<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>if<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">C</code>conforms to<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code>,&quot; and &quot;<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">C</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>derives<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>if<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">A</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>conforms to<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code>.&quot; The same observation about recursion and the finiteness of instances from above holds here, so we can generalize the rule above as follows:</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><span style="box-sizing:border-box;font-weight:600">A type<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">T</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>can derive<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>if all members of<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">T</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>conform to<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>or are of types found in cycles that lead back to<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">T</code>such that the members of those other types along the cycle also all conform to<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">P</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>or are themselves along such a cycle.</span></p><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_-4999436824520193668m_-2449579574363835825inbox-inbox-user-content-other-considerations" class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#other-considerations" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Other considerations</h3><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">When conditional conformances are supported in Swift, generic types should conditionally derive<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Equatable</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>and<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Hashable</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>for type argument substitutions where the rules above are satisfied.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">A notable side effect of this is that<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Optional&lt;Wrapped&gt;</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>would derive<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Equatable</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>and<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Hashable</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>conformance when<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Wrapped</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>conforms to those protocols, because it is an<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">enum</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>that would satisfy the rules described above. Its implementation would not need to be in the standard library (but there is also nothing preventing it from being there).</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">Conditional conformances will also significantly improve derivability coverage over other payload/member types. For example, consider a<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">struct</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>containing a stored property that is an array of<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Equatable</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>types:</p><div class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-highlight m_-4999436824520193668m_-2449579574363835825inbox-inbox-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal"><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">struct</span> <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Foo</span> {
  <span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> values<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span> [<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span>]
}</pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">Today,<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Array&lt;String&gt;</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>does not conform to<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Equatable</code>, so its presence would prohibit<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Foo</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>from deriving<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Equatable</code>. However, once Swift can express the conformance<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Array&lt;Element&gt;: Equatable where Element: Equatable</code>,<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Foo</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>would automatically derive<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Equatable</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>as well. This makes derived conformances significantly more powerful.</p><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_-4999436824520193668m_-2449579574363835825inbox-inbox-user-content-implementation-details" class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#implementation-details" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Implementation details</h3><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">An<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">enum T</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>that derives<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Equatable</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>will receive a compiler-generated implementation of<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">static == (lhs: T, rhs: T) -&gt; Bool</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>that returns<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">true</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>if and only if<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">lhs</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>and<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">rhs</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>are the same case and have payloads that are memberwise-equal.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">An<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">enum T</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>that derives<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Hashable</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>will receive a compiler-generated implementation of<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">var hashValue: Int { get }</code>that uses an unspecified hash function<span style="box-sizing:border-box;font-size:12px;line-height:0;vertical-align:baseline">†</span><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>to compute the hash value by incorporating the case&#39;s ordinal (i.e., definition order) followed by the hash values of its associated values as its terms, also in definition order.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">A<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">struct T</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>that derives<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Equatable</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>will receive a compiler-generated implementation of<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">static == (lhs: T, rhs: T) -&gt; Bool</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>that returns<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">true</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>if and only if<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">lhs.x == rhs.x</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>for all stored properties in<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">T</code>.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">A<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">struct T</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>that derives<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Hashable</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>will receive a compiler-generated implementation of<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">var hashValue: Int { get }</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>that uses an unspecified hash function<span style="box-sizing:border-box;font-size:12px;line-height:0;vertical-align:baseline">†</span><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>to compute the hash value by incorporating the hash values of the fields as its terms, in definition order.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><span style="box-sizing:border-box;font-size:12px;line-height:0;vertical-align:baseline">†</span><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>We intentionally leave the exact definition of the hash function unspecified here. A multiplicative hash function with good distribution is the likely candidate, but we do not rule out other possibilities. Users should not depend on the nature of the generated implementation or rely on particular outputs; we reserve the right to change it in the future.</p><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_-4999436824520193668m_-2449579574363835825inbox-inbox-user-content-overriding-derived-conformances" class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#overriding-derived-conformances" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Overriding derived conformances</h3><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">Any user-provided implementations of<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">==</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>or<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">hashValue</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>will override the default implementations that would be provided by the compiler. This is already the case possible today with raw-value enums so the same behavior should be extended to other value types that are made to implicitly conform to these protocols.</p><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_-4999436824520193668m_-2449579574363835825inbox-inbox-user-content-open-questions" class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#open-questions" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Open questions</h3><h4 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:16px;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_-4999436824520193668m_-2449579574363835825inbox-inbox-user-content-omission-of-fields-from-generated-computations" class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#omission-of-fields-from-generated-computations" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Omission of fields from generated computations</h4><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">Some commenters have expressed a desire to tag certain properties of a<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">struct</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>from being included in automatically generated equality tests or hash value computations. This could be valuable, for example, if a property is merely used as an internal cache and does not actually contribute to the &quot;value&quot; of the instance. Under the rules above, if this cached value was equatable, a user would have to override<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">==</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>and<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">hashValue</code><span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span>and provide their own implementations to ignore it.</p><h4 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:16px;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_-4999436824520193668m_-2449579574363835825inbox-inbox-user-content-explicit-or-implicit-derivation" class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#explicit-or-implicit-derivation" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Explicit or implicit derivation</h4><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">As with raw-value enums today, should the derived conformance be completely implicit, or should users have to explicitly list conformance with<span class="m_-4999436824520193668m_-2449579574363835825inbox-inbox-Apple-converted-space"> </span></p></div></div></div></blockquote></div></div></div></div></blockquote></div></div></blockquote></div></div></blockquote></div>