[Haskell-cafe] ANN: To Kata Haskellen Evangelion
dsf at seereason.com
Fri Aug 2 21:42:19 UTC 2019
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.
On Sun, Jul 28, 2019 at 8:51 AM David Fox <dsf at seereason.com> wrote:
> On page 39 you say
> A type can have Ord instance only when it has Eq instance, since if
>> you want to compare items, you need a way to test if they are equal.
> 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.
> On Sun, Jul 28, 2019 at 2:38 AM Cosmia Fu <cosmiafu at gmail.com> wrote:
>> Hi everyone,
>> Though some of you might already knows, I'm pleased to announce a new
>> Haskell book,
>> *To Kata Haskellen Evangelion*.
>> Link: https://cosmius.bitbucket.io/tkhe/
>> I believe that it does not have to be hard to learn Haskell.
>> I begun to write the book in 2017 December, and... to be honest,
>> I don't know what to write now, though I still think it incomplete.
>> It will probably not be updated for quite a while.
>> So I decide to announce it earlier.
>> I am not a native English speaker, so it might be not fluent or even with
>> a lot of grammar mistakes.
>> It would be very nice of you if you can tell me the mistakes in it,
>> factual, technical or grammar.
>> And also feel free to tell me if you want to read some topic in it.
>> Thank you
>> Cosmia Fu
>> Haskell-Cafe mailing list
>> To (un)subscribe, modify options or view archives go to:
>> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe