I should add, requiring opt-in doesn&#39;t necessarily mean one must break source compatibility for enums currently with derived equality. That can be grandfathered in.<br><br>Later, we can even explore more comprehensive functionality when an enum is declared &quot;Foo : Int&quot;. In my opinion, the ideal endpoint in Swift N (where N &gt;&gt; 4) is true value subtyping; absent that, it would only make sense that Foo would at least conform to all the protocols to which Int conforms. A longer-term discussion clearly out of scope here, but mentioned only to say that existing magic doesn&#39;t need to be rolled back necessarily.<br><br>While we&#39;re on this topic though, it&#39;d be really nice to revisit Equatable and Hashable for tuples; that&#39;s one place where implicit magic may be the best way to go. Currently, tuples of arity 6 or less benefit from a manual hack to be Equatable, but we can clearly do better.<br><br><div class="gmail_quote"><div dir="ltr">On Thu, May 4, 2017 at 17:01 Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com">xiaodi.wu@gmail.com</a>&gt; wrote:<br></div><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 dir="ltr">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 dir="ltr"><div>Hi all,</div><div><br></div>A conversation on Twitter last night brought up some interest in this feature and I was encouraged to revive this proposal.<div><br></div><div>Jordan Rose <a href="https://twitter.com/UINT_MIN/status/859922619578986496" target="_blank">mentioned</a> on Twitter that it could possibly make it in by the Swift 4 deadline if others contributed—I have a WIP branch (albeit not currently working because I rebased after a couple months of it being idle) that does the work for enums but I got stuck on the mutually recursive cases. If this got approved, I&#39;d love to collaborate with other interested folks to finish up the implementation.</div><div><br></div><div>Link: <a href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad" target="_blank">https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad</a></div><div><br></div><div><br></div><div><h1 style="box-sizing:border-box;margin:0px 0px 16px;line-height:1.25;padding-bottom:0.3em;border-bottom:1px solid rgb(234,236,239);color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;">Deriving<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>and<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-user-content-introduction" class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>and<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-user-content-motivation" class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-highlight m_-315499732622462706m_-7001013475466848454inbox-inbox-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal"><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">struct</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Foo</span>: <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-e" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Equatable</span> </span>{
  <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">static</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">func</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">==</span> (<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">lhs</span></span>: Foo, <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">rhs</span></span>: Foo) <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">-&gt;</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Bool</span> {
    <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> lhs.<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property1</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> rhs.<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property1</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">&amp;&amp;</span>
           lhs.<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property2</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> rhs.<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property2</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">&amp;&amp;</span>
           lhs.<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property3</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> rhs.<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">property3</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">&amp;&amp;</span>
           <span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>or use one as a multi-valued<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-highlight m_-315499732622462706m_-7001013475466848454inbox-inbox-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal"><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Token</span>: <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-e" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Equatable</span> </span>{
  <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">string</span>(<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span>)
  <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">number</span>(<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Int</span>)
  <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">lparen</span>
  <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">rparen</span>
  
  <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">static</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">func</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">==</span> (<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">lhs</span></span>: Token, <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">rhs</span></span>: Token) <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">-&gt;</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Bool</span> {
    <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">switch</span> (lhs, rhs) {
    <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> (.<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">string</span>(<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> lhsString), .<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">string</span>(<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> rhsString))<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
      <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> lhsString <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> rhsString
    <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> (.<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">number</span>(<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> lhsNumber), .<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">number</span>(<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> lhsNumber))<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
      <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> lhsNumber <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> rhsNumber
    <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> (.<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">lparen</span>, .<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">lparen</span>), (.<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">rparen</span>, .<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">rparen</span>)<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
      <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">true</span>
    <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">default</span><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
      <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> <span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>and<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-highlight m_-315499732622462706m_-7001013475466848454inbox-inbox-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal"><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Foo</span>  {
  <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">zero</span>, <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">one</span>, <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">two</span>
}

<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> x <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> (Foo.<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">one</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> Foo.<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">two</span>)  <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c" style="box-sizing:border-box">//</span> evaluates to false</span>
<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> y <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> Foo.<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">one</span>.<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">hashValue</span>     <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-user-content-proposed-solution" class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>if all of its members are<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-user-content-protocol-derivability-conditions" class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>represent either the protocol<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>or<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-user-content-derived-conformances-for-enums" class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>can be derived for an<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>with no cases does not derive conformance to<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>with one or more cases derives conformance to<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>if all of the associated values of all of its cases conform to<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-user-content-derived-conformances-for-structs" class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>is based on the conformances of its stored instance properties<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>can be derived for a<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>with<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">no</em><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>stored properties does<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">not</em><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>derive conformance to<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>with one or more stored properties derives conformance to<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>if all if the types of all of its stored properties conform to<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-user-content-considerations-for-recursive-types" class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">members</em><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>refers only to those members that are checked for deriving conformances:<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">stored properties</em><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>for<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">associated values</em><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>for<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>with an<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>case:</p><div class="m_-315499732622462706m_-7001013475466848454inbox-inbox-highlight m_-315499732622462706m_-7001013475466848454inbox-inbox-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal"><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">TreeNode</span> {
  <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">empty</span>
  <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">leaf</span>(<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">value</span></span>: <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Int</span>)
  <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">internal</span>(<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">left</span></span>: TreeNode, <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>derives<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>if<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>conforms to<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>derives<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>that any members of type<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>already conform to<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>If any members of different types prohibit deriving<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">mutually</em><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>recursive types as well. Consider this contrived example:</p><div class="m_-315499732622462706m_-7001013475466848454inbox-inbox-highlight m_-315499732622462706m_-7001013475466848454inbox-inbox-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal"><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">A</span> {
  <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">value</span>(<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Int</span>)
  <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">b</span>(B)
}

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

<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">C</span> {
  <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">value</span>(<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Double</span>)
  <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>derives<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>if<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>conforms to<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>derives<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>if<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>derives<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>if<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>conforms to<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>can derive<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>if all members of<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>conform to<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>or are of types found in cycles that lead back to<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-user-content-other-considerations" class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>and<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>would derive<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>and<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>conformance when<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>conforms to those protocols, because it is an<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>containing a stored property that is an array of<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>types:</p><div class="m_-315499732622462706m_-7001013475466848454inbox-inbox-highlight m_-315499732622462706m_-7001013475466848454inbox-inbox-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal"><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">struct</span> <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Foo</span> {
  <span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> values<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span> [<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>does not conform to<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>from deriving<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>would automatically derive<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-user-content-implementation-details" class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>that derives<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>will receive a compiler-generated implementation of<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>that returns<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>if and only if<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>and<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>that derives<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>will receive a compiler-generated implementation of<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>that derives<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>will receive a compiler-generated implementation of<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>that returns<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>if and only if<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>for all stored properties in<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>that derives<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>will receive a compiler-generated implementation of<span class="m_-315499732622462706m_-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_-315499732622462706m_-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_-315499732622462706m_-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"><span style="box-sizing:border-box;font-size:12px;line-height:0;vertical-align:baseline">†</span><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>We intentionally leave the exact definition of the hash function unspecified here. A multiplicative hash function with good distribution is the likely candidate, but we do not rule out other possibilities. Users should not depend on the nature of the generated implementation or rely on particular outputs; we reserve the right to change it in the future.</p><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_-315499732622462706m_-7001013475466848454inbox-inbox-user-content-overriding-derived-conformances" class="m_-315499732622462706m_-7001013475466848454inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#overriding-derived-conformances" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Overriding derived conformances</h3><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">Any user-provided implementations of<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>or<span class="m_-315499732622462706m_-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">hashValue</code><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>will override the default implementations that would be provided by the compiler. This is already the case possible today with raw-value enums so the same behavior should be extended to other value types that are made to implicitly conform to these protocols.</p><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_-315499732622462706m_-7001013475466848454inbox-inbox-user-content-open-questions" class="m_-315499732622462706m_-7001013475466848454inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#open-questions" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Open questions</h3><h4 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:16px;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_-315499732622462706m_-7001013475466848454inbox-inbox-user-content-omission-of-fields-from-generated-computations" class="m_-315499732622462706m_-7001013475466848454inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#omission-of-fields-from-generated-computations" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Omission of fields from generated computations</h4><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">Some commenters have expressed a desire to tag certain properties of a<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>from being included in automatically generated equality tests or hash value computations. This could be valuable, for example, if a property is merely used as an internal cache and does not actually contribute to the &quot;value&quot; of the instance. Under the rules above, if this cached value was equatable, a user would have to override<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>and<span class="m_-315499732622462706m_-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">hashValue</code><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>and provide their own implementations to ignore it.</p><h4 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:16px;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_-315499732622462706m_-7001013475466848454inbox-inbox-user-content-explicit-or-implicit-derivation" class="m_-315499732622462706m_-7001013475466848454inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#explicit-or-implicit-derivation" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Explicit or implicit derivation</h4><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">As with raw-value enums today, should the derived conformance be completely implicit, or should users have to explicitly list conformance with<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>and<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>in order for the compiler to generate the derived implementation?</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">If derived conformances were made explicit, it could be argued that this should also be done for consistency across raw-value enums as well. This would be a source-breaking change, which should be avoided at this stage.</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_-315499732622462706m_-7001013475466848454inbox-inbox-user-content-impact-on-existing-code" class="m_-315499732622462706m_-7001013475466848454inbox-inbox-anchor" href="https://gist.github.com/allevato/2fd10290bfa84accfbe977d8ac07daad#impact-on-existing-code" 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>Impact on existing code</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">This change would make types that satisfy the rules above<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>and<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>when they previously were not. It is not expected that there would be any<span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">behavioral</em><span class="m_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>changes because of this; since<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>and<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>have associated type requirements, users cannot be dynamically testing for conformance to them at runtime.</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">Value types that already provide custom implementations of<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>and<span class="m_-315499732622462706m_-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_-315499732622462706m_-7001013475466848454inbox-inbox-Apple-converted-space"> </span>would keep the custom implementation because it would override the compiler-provided default.</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 change would potentially increase binary size when it generates conformances that did not exist before, a</p></div></div></blockquote></div></blockquote></div>