<div dir="ltr">But it's hard to specify the "constraint" / completeness condition (see the MINIMAL pragma) of "can be fully expressed via constructors". Note also that this doesn't work for numbers: you can use constructor syntax, but it's desugared to (==). So it's inviting confusion in a number of ways, including some that don't matter directly (you're unlikely to write your own Ord instance for numbers like that) but matter for understanding how the language fits together, which is already confused by e.g. above "sugar".</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 30, 2019 at 8:23 AM Richard O'Keefe <<a href="mailto:raoknz@gmail.com">raoknz@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 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" target="_blank">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_1700558064333781432gmail-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_1700558064333781432gmail-m_3880703966026411249gmail-m_5471475749209884360m_6581403943012399177gmail_signature"><br></div><div class="gmail-m_1700558064333781432gmail-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_1700558064333781432gmail-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_1700558064333781432gmail-m_3880703966026411249gmail-m_5471475749209884360m_6581403943012399177gmail_signature">It will
probably not be updated for quite a while.</div><div class="gmail-m_1700558064333781432gmail-m_3880703966026411249gmail-m_5471475749209884360m_6581403943012399177gmail_signature">So I decide to announce it earlier.</div><div class="gmail-m_1700558064333781432gmail-m_3880703966026411249gmail-m_5471475749209884360m_6581403943012399177gmail_signature"><br></div><div class="gmail-m_1700558064333781432gmail-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_1700558064333781432gmail-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_1700558064333781432gmail-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_1700558064333781432gmail-m_3880703966026411249gmail-m_5471475749209884360m_6581403943012399177gmail_signature">Thank you<br></div><div dir="ltr" class="gmail-m_1700558064333781432gmail-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>
_______________________________________________<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 clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>brandon s allbery kf8nh</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a></div></div></div></div></div>