<div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace">This is a classic ambiguity in "since".</div><div class="gmail_default" style="font-family:monospace,monospace">Here it's sort of epistemic:</div><div class="gmail_default" style="font-family:monospace,monospace">   If you know how to do a three way comparison on T</div><div class="gmail_default" style="font-family:monospace,monospace">   then you must know how to test equality on T</div><div class="gmail_default" style="font-family:monospace,monospace">   therefore it is reasonable for anything that implements Ord to implement Eq as well</div><div class="gmail_default" style="font-family:monospace,monospace">   and it would confuse people a lot if <= and >= were allowed but not ==</div><div class="gmail_default" style="font-family:monospace,monospace">   so Haskell requires instances of Ord to also be instances of Eq.</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">You are right:</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">data T = A | B<br>  <br>instance Ord T<br>  where compare A A = EQ<br>        compare A B = LT<br>        compare B A = GT<br>        compare B B = EQ<br><br>instance Eq T<br>  where x == y = compare x y == EQ<br></div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">appears to be legal Haskell.  GHC is happy with it and it seems to work.</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 29 Jul 2019 at 03:52, David Fox <<a href="mailto:dsf@seereason.com">dsf@seereason.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-size:small">On page 39 you say</div><div class="gmail_default" style="font-size:small"><br></div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">    A type can have<span class="gmail_default" style="font-size:small"> </span>Ord<span class="gmail_default" style="font-size:small"> i</span>nstance<span class="gmail_default" style="font-size:small"> </span>only when it has<span class="gmail_default" style="font-size:small"> </span>Eq<span class="gmail_default" style="font-size:small"> </span>instance, since if you want to compare items, you need a way to test if<span class="gmail_default" style="font-size:small"> </span>they are equal.</blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">So from my reading of this you are saying that an Eq instance for a type needs to be supplied before we are allowed to implement compare.  However it is easy to write a compare function that makes no use of the underlying (==) function.  Indeed, once you have done this you can turn around and write a == b = compare a b == EQ.  So I was wondering if you could clarify the role of constraints in the class declaration.<br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jul 28, 2019 at 2:38 AM Cosmia Fu <<a href="mailto:cosmiafu@gmail.com" target="_blank">cosmiafu@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi everyone,</div><div><br></div><div>Though some of you might already knows, I'm pleased to announce a new Haskell book,</div><div><i>To Kata Haskellen Evangelion</i>.<br></div><div>Link: <a href="https://cosmius.bitbucket.io/tkhe/" target="_blank">https://cosmius.bitbucket.io/tkhe/</a></div><div><div><div class="gmail-m_3880703966026411249gmail-m_5471475749209884360m_6581403943012399177gmail_signature">I believe that it does not have to be hard to learn Haskell.<br></div><div dir="ltr" class="gmail-m_3880703966026411249gmail-m_5471475749209884360m_6581403943012399177gmail_signature"><br></div><div class="gmail-m_3880703966026411249gmail-m_5471475749209884360m_6581403943012399177gmail_signature">I begun to write the book in 2017 December, and... to be honest,<br></div><div class="gmail-m_3880703966026411249gmail-m_5471475749209884360m_6581403943012399177gmail_signature">I don't know what to write now, though I still think it incomplete.</div><div class="gmail-m_3880703966026411249gmail-m_5471475749209884360m_6581403943012399177gmail_signature">It will 
probably not be updated for quite a while.</div><div class="gmail-m_3880703966026411249gmail-m_5471475749209884360m_6581403943012399177gmail_signature">So I decide to announce it earlier.</div><div class="gmail-m_3880703966026411249gmail-m_5471475749209884360m_6581403943012399177gmail_signature"><br></div><div class="gmail-m_3880703966026411249gmail-m_5471475749209884360m_6581403943012399177gmail_signature">I am not a native English speaker, so it might be not fluent or even with a lot of grammar mistakes.</div><div class="gmail-m_3880703966026411249gmail-m_5471475749209884360m_6581403943012399177gmail_signature">It would be very nice of you if you can tell me the mistakes in it, factual, technical or grammar.</div><div class="gmail-m_3880703966026411249gmail-m_5471475749209884360m_6581403943012399177gmail_signature">And also feel free to tell me if you want to read some topic in it.<br></div><br><div class="gmail-m_3880703966026411249gmail-m_5471475749209884360m_6581403943012399177gmail_signature">Thank you<br></div><div dir="ltr" class="gmail-m_3880703966026411249gmail-m_5471475749209884360m_6581403943012399177gmail_signature"><br>----<br><br>Cosmia Fu<br></div></div></div></div>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>