<div dir="ltr">It isn&#39;t explicit that you are synthesizing code. This is especially true because we can still declare conformance on one declaration/extension and implement in another. You could even conform in another file. This isn&#39;t generally good form but it is valid code and it is even, in some cases, somewhat reasonable.(You might have moved an extension or it might be relevant to some other bit of code somewhere but you want the conformance visible on the declaration because it is of prime importance.</div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, May 28, 2016 at 7:43 PM, Pedro Vieira via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I really think this would be a great addition to Swift. Although, I don&#39;t see the need to use a new keyword `deriving` for this feature.<div>The following would be enough:<br><div><br></div><div><div>struct Foo: Equatable, Hashable {</div><div>  ...</div><div>}</div><div><br></div><div>It&#39;s explicit and it uses features already in the language. With this, the compiler would generate all the functions needed for `Foo` to conform to `Equatable` and `Hashable` and, in case the developer wants custom behavior on any of those functions, he/she could just write it from scratch and the compiler would use it over the generated one.</div></div></div><br><div class="gmail_quote"><span class=""><div dir="ltr">Michael Peternell via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; escreveu no dia quinta, 26/05/2016 às 10:58:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Can we just copy&amp;paste the solution from Haskell instead of creating our own? It&#39;s just better in every aspect. Deriving `Equatable` and `Hashable` would become<br>
<br>
struct Polygon deriving Equatable, Hashable {<br>
    ...<br>
}<br>
<br>
This has several advantages:<br>
- you don&#39;t have to guess wether `Equatable` or `Hashable` should be automatically derived or not.<br>
- Deriving becomes an explicit choice.<br>
- If you need a custom `Equatable` implementation (for whatever reason), you can still do it.<br>
- It doesn&#39;t break any code that is unaware of the change<br>
- It can be extended in future versions of Swift, without introducing any new incompatibilities. For example, `CustomStringConvertible` could be derived just as easily.<br>
- It is compatible with generics. E.g. `struct Shape&lt;T&gt; deriving Equatable` will make every `Shape&lt;X&gt;` equatable if `X` is equatable. But if `X` is not equatable, `Shape&lt;X&gt;` can be used as well. (Unless `X` is not used, in which case every `Shape&lt;T&gt;` would be equatable. Unless something in the definition of `Shape` makes deriving `Equatable` impossible =&gt; this produces an error.)<br>
- It is proven to work in production.<br>
<br>
-Michael<br></blockquote><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px"><br></span></div></span><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">Pedro Vieira</span><br></div><div style="font-size:13px;color:rgb(34,34,34);font-family:arial,sans-serif"><a href="http://pedrovieira.me/" target="_blank">http://pedrovieira.me</a></div></div></div><span class="HOEnZb"><font color="#888888"><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr"><span style="color:rgb(34,34,34);font-family:arial,sans-serif">Pedro Vieira</span><div style="color:rgb(34,34,34);font-family:arial,sans-serif"><a href="http://pedrovieira.me/" target="_blank">http://pedrovieira.me</a></div></div></div>
</font></span><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>