<div>I&#39;m imagining no syntax; effectively, as though there exists an &quot;extension Equatable where [ all members : Equatable ]&quot; with a default implementation.</div><div><br></div><div><br><div class="gmail_quote"><div>On Thu, May 4, 2017 at 17:13 John McCall &lt;<a href="mailto:rjmccall@apple.com">rjmccall@apple.com</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 4, 2017, at 6:10 PM, Andrew Bennett via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><div><div>I agree, let&#39;s make it opt-in.<div><br></div><div>This looks really great, I&#39;m excited to get generated conformance for Equatable/Hashable in time for Swift 4.</div><div><br></div><div>I think it&#39;s worth mentioning that Encoding/Decoding generated conformance is already accepted and implemented in Swift 4. The implementation and acceptance criterion for Equatable/Hashable is likely to be very similar.</div><div><br></div><div><b>For the open questions</b>, I think for the sake of getting this into Swift 4 we should go for explicit derivation, and don&#39;t allow omission of fields (yet).</div></div></div></blockquote><div><br></div></div></div><div style="word-wrap:break-word"><div>Is there a syntax proposal for explicit derivation?  Or are you imagining that just declaring the conformance but failing to implement it should trigger derivation?</div></div><div style="word-wrap:break-word"><div><br></div><div>John.</div></div><div style="word-wrap:break-word"><div><br><blockquote type="cite"><div><div><div><br></div><div>Omission is nice-to-have, but likely to be a long-winded bike-shed.</div><div><br></div><div>Changing from explicit to implicit is a loss of information, and has a large impact on the language, it can&#39;t easily be undone, so it requires a large discussion when it&#39;s decided. It only adds a little additional convenience to the user though.</div><div><br></div><div>I suggest we discuss implicit generation and allowing omission with follow-up proposals, they will very likely be additive non-breaking changes. For this proposal we play it safe and stick to explicit conformance and no omission of fields.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 5, 2017 at 8:01 AM, Xiaodi Wu via swift-evolution <span>&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hmm, I can see the appeal of automatically deriving Equatable and Hashable conformance, but I&#39;d like that to be opt-in. That is, types should declare that they are Equatable or Hashable to begin with. It wouldn&#39;t have to take extra syntax, as compiler magic could effectively synthesize default implementations for == and/or hashValue when all members are themselves Equatable or Hashable, respectively. With such a scheme, consideration can be made to accommodating classes too.<br><div class="gmail_quote"><div>On Thu, May 4, 2017 at 15:37 Tony Allevato 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><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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>and<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-user-content-introduction" class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>and<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-user-content-motivation" class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight-source-swift m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight" 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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">struct</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Foo</span>: <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-e" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Equatable</span> </span>{
  <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">static</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">func</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">==</span> (<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">lhs</span></span>: Foo, <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">rhs</span></span>: Foo) <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">-&gt;</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Bool</span> {
    <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> lhs.<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property1</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> rhs.<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property1</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">&amp;&amp;</span>
           lhs.<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property2</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> rhs.<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property2</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">&amp;&amp;</span>
           lhs.<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property3</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> rhs.<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property3</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">&amp;&amp;</span>
           <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>or use one as a multi-valued<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight-source-swift m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight" 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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Token</span>: <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-e" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Equatable</span> </span>{
  <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">string</span>(<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span>)
  <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">number</span>(<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Int</span>)
  <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">lparen</span>
  <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">rparen</span>
  
  <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">static</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">func</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">==</span> (<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">lhs</span></span>: Token, <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">rhs</span></span>: Token) <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">-&gt;</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Bool</span> {
    <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">switch</span> (lhs, rhs) {
    <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> (.<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">string</span>(<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> lhsString), .<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">string</span>(<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> rhsString))<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
      <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> lhsString <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> rhsString
    <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> (.<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">number</span>(<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> lhsNumber), .<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">number</span>(<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> lhsNumber))<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
      <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> lhsNumber <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> rhsNumber
    <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> (.<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">lparen</span>, .<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">lparen</span>), (.<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">rparen</span>, .<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">rparen</span>)<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
      <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">true</span>
    <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">default</span><span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
      <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>and<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight-source-swift m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight" 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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Foo</span>  {
  <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">zero</span>, <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">one</span>, <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">two</span>
}

<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> x <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> (Foo.<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">one</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> Foo.<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">two</span>)  <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c" style="box-sizing:border-box">//</span> evaluates to false</span>
<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> y <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> Foo.<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">one</span>.<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">hashValue</span>     <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-user-content-proposed-solution" class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>if all of its members are<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-user-content-protocol-derivability-conditions" class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>represent either the protocol<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>or<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-user-content-derived-conformances-for-enums" class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>can be derived for an<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>with no cases does not derive conformance to<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>with one or more cases derives conformance to<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>if all of the associated values of all of its cases conform to<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-user-content-derived-conformances-for-structs" class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>is based on the conformances of its stored instance properties<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>can be derived for a<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>with<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">no</em><span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>stored properties does<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">not</em><span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>derive conformance to<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>with one or more stored properties derives conformance to<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>if all if the types of all of its stored properties conform to<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-user-content-considerations-for-recursive-types" class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">members</em><span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>refers only to those members that are checked for deriving conformances:<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">stored properties</em><span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>for<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">associated values</em><span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>for<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>with an<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>case:</p><div class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight-source-swift m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight" 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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">TreeNode</span> {
  <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">empty</span>
  <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">leaf</span>(<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">value</span></span>: <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Int</span>)
  <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">internal</span>(<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">left</span></span>: TreeNode, <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>derives<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>if<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>conforms to<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>derives<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>that any members of type<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>already conform to<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>If any members of different types prohibit deriving<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">mutually</em><span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>recursive types as well. Consider this contrived example:</p><div class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight-source-swift m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight" 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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">A</span> {
  <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">value</span>(<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Int</span>)
  <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">b</span>(B)
}

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

<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">C</span> {
  <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">value</span>(<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Double</span>)
  <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>derives<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>if<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>conforms to<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>derives<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>if<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>derives<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>if<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>conforms to<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>can derive<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>if all members of<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>conform to<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>or are of types found in cycles that lead back to<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-user-content-other-considerations" class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>and<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>would derive<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>and<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>conformance when<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>conforms to those protocols, because it is an<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>containing a stored property that is an array of<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>types:</p><div class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight-source-swift m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-highlight" 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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">struct</span> <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Foo</span> {
  <span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> values<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span> [<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>does not conform to<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>from deriving<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>would automatically derive<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-user-content-implementation-details" class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>that derives<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>will receive a compiler-generated implementation of<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>that returns<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>if and only if<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>and<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>that derives<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>will receive a compiler-generated implementation of<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>that derives<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>will receive a compiler-generated implementation of<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>that returns<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>if and only if<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>for all stored properties in<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>that derives<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>will receive a compiler-generated implementation of<span class="m_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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_3988002835138234871m_-250763368739857023m_-7001013475466848454inbox-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"></p></div></div></blockquote></div></blockquote></div></div></div></blockquote></div></div></blockquote></div></div>