[Haskell-cafe] Eq source code?

Galaxy Being borgauf at gmail.com
Fri Apr 2 15:37:07 UTC 2021


While learning about type classes, I tried to find the actual source code
for Eq. In my beginner books this much is typically given

class Eq a where
  (==), (/=) :: a -> a -> Bool

-- Minimal completion definition:
  x /= y = not (x == y)
  x == y = not (x /= y)

I then found this
<https://hackage.haskell.org/package/base-4.15.0.0/docs/Data-Eq.html> at
hackage.haskell.org, but the "source" links are dead. On this page is a
section of what I can't tell is either source code or just commentary on
all the different mathematical ideas about equality, i.e.,

Reflexivity
x == x = True
Symmetry
x == y = y == x
Transitivity
if x == y && y == z = True, then x == z = True
Substitutivity
if x == y = True and f is a "public" function whose return type is an
instance of Eq, then f x == f y = True
Negation
x /= y = not (x == y)

I would like to know if this is indeed in the source code or if it's just a
sort of commentary. It looks important. Where can I find the actual source
for all these basic type classes?

LB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20210402/cfff9b88/attachment.html>


More information about the Haskell-Cafe mailing list