<div dir="ltr"><div class="gmail_default" style="font-size:small">I would say that the constraint means you can assume that the Eq instance exists when writing your Ord instance. If you try to write an Ord instance for a type with no Eq instance the compiler will complain, even though it might be possible to write the instance without using the Eq instance. I would mention that putting constraints on the class is often overkill, it may be better to put them on the individual instances as needed. But that may be too much information for a beginner.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jul 28, 2019 at 8:51 AM 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_1301248348607018742gmail-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_1301248348607018742gmail-m_5471475749209884360m_6581403943012399177gmail_signature"><br></div><div class="gmail-m_1301248348607018742gmail-m_5471475749209884360m_6581403943012399177gmail_signature">I begun to write the book in 2017 December, and... to be honest,<br></div><div class="gmail-m_1301248348607018742gmail-m_5471475749209884360m_6581403943012399177gmail_signature">I don't know what to write now, though I still think it incomplete.</div><div class="gmail-m_1301248348607018742gmail-m_5471475749209884360m_6581403943012399177gmail_signature">It will
probably not be updated for quite a while.</div><div class="gmail-m_1301248348607018742gmail-m_5471475749209884360m_6581403943012399177gmail_signature">So I decide to announce it earlier.</div><div class="gmail-m_1301248348607018742gmail-m_5471475749209884360m_6581403943012399177gmail_signature"><br></div><div class="gmail-m_1301248348607018742gmail-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_1301248348607018742gmail-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_1301248348607018742gmail-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_1301248348607018742gmail-m_5471475749209884360m_6581403943012399177gmail_signature">Thank you<br></div><div dir="ltr" class="gmail-m_1301248348607018742gmail-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>
</blockquote></div>