<div><div dir="auto">The close family with nonlinear matching does seem simpler.  Like I can comfortably read it and understand what it does reasonably well and have uniform expectations of what it means. </div><div dir="auto"><br></div><div dir="auto">That said, I'm open to be swayed otherwise.  The </div><br><div class="gmail_quote"><div>On Fri, Aug 11, 2017 at 11:44 AM Richard Eisenberg <<a href="mailto:rae@cs.brynmawr.edu">rae@cs.brynmawr.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>tl;dr: I like David's first version, D3835.</div><div><br></div><div>There is a fundamental tension in the definition of (==): Should it be reflexive or not? By "reflexive" here, I mean that (a == a) reduces to True, even if you know nothing further about a. The current definition of (==) is reflexive in this way for types of kind Type, but not for any of the other concrete instances (except the one for ()).</div><div><br></div><div>We can't currently have our cake and it eat, too: as David points out in this thread, (==) is either reflexive or structurally recursive. It can't do both. Possibly a solution to #4259 (<a href="https://ghc.haskell.org/trac/ghc/ticket/4259" target="_blank">https://ghc.haskell.org/trac/ghc/ticket/4259</a>) would allow us to have (==) that is both reflexive and structurally recursive, but I have no idea how to do it.</div><div><br></div><div>I agree that the current choice of implementation for (==) is inconsistent in this regard and is perhaps foolish. I have no principled argument for why it is the way it is. But I wonder if we're better off embracing the distinction between a reflexive (==) and a structurally recursive (==) and provide both, with different names. Or, we could just decide to go with the structurally recursive one, which seems to be more useful, especially as I have become much more skeptical of non-linear patterns (necessary for the reflexive (==)). In particular, I don't have a good story for how they would work in Dependent Haskell. Section 5.13.2 of my thesis (<a href="http://cs.brynmawr.edu/~rae/papers/2016/thesis/eisenberg-thesis.pdf" target="_blank">http://cs.brynmawr.edu/~rae/papers/2016/thesis/eisenberg-thesis.pdf</a>) contains some technical discussion of the challenges, but that section may not be digestible on its own. </div><div><br></div><div>The point of difference between David's two proposed changes is extensibility: that is, could someone decide to have a custom equality operator on a user-defined type? This is indeed a reasonable thing to want -- for example, you could imagine a record system that stores names of fields and their types in a type-level list, but that list should really be regarded as a set. However, worms lurk under this stone. If we have a more flexible notion of equality, how can we be sure that this more inclusive equality is always respected? Specifically, you would want this: if (ty1 == ty2) and ty1 is substituted for ty2 in some context, everything still works. Sadly, there is no way to guarantee such a property. If (==) is to be useful in a type system, we would need such a guarantee. (By "useful", I mean that this is implementable: reifyEq :: ((a == b) ~ True, Typeable a, Typeable b) => a :~: b.) This brings us to the doorstep of higher inductive types -- a door that might be fun to enter, but is a long long way off.</div><div><br></div><div>In sum, I argue for David's first, inextensible version.</div><div><br></div><div>By the way, nothing about this requires TypeInType. If I had thought of David's version (that splits apart type applications) in 2013, I probably would have implemented (==) that way.</div></div><div style="word-wrap:break-word"><div><br></div><div>Richard</div></div><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On Aug 10, 2017, at 9:00 PM, David Feuer <<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>> wrote:</div><br class="m_8494142472944492435Apple-interchange-newline"><div><div dir="auto">I tend to agree with you, although I don't think () is a compelling argument. Rather,  it reuses the name == that Haskellers are accustomed to defining flexibly. But for that same reason, as well as the convenience, I do think we should consider using a kind class. That way things at the type level look pretty much like they do at the term level.</div><div class="gmail_extra"><br><div class="gmail_quote">On Aug 10, 2017 10:59 AM, "Ryan Scott" <<a href="mailto:ryan.gl.scott@gmail.com" target="_blank">ryan.gl.scott@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Personally, I'd be more inclined towards latter approach (in<br>
<a href="https://phabricator.haskell.org/D3837" rel="noreferrer" target="_blank">https://phabricator.haskell.org/D3837</a>). After all, one of the key<br>
properties of (==) (for which the Haddocks even make a special note)<br>
is that it does not attempt to provide an instance that works for<br>
every possible kind. Indeed, as you've discovered, there are cases<br>
when it doesn't make sense to use DefaultEq, such as for ().<br>
<br>
I'll tentatively give my support for D3837, although I'd be curious to<br>
hear what Richard has to say about this (since I'm reasonably<br>
confident he gave (==) its current implementation).<br>
<br>
Ryan S.<br>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div></div>
_______________________________________________<br>Libraries mailing list<br><a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br></div></blockquote></div><br></div>_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div></div>