I’m trying to understand the relationship between data types/declarations, classes and instances.
I’m looking at data Double and class Eq a that I found using Hoogle, and both show the instance Eq Double
. However, my understanding is there is only one instance and searching GHC code for “instance Eq Double” only shows up once in libraries/ghc-prim/GHC/Classes.hs
.
So I’m wondering if the instance Eq Double
is
- part of
class Eq a
, - part of
data Double
- or really neither, perhaps an independent thing that ties the two together.
The language used by books and articles is confusing (maybe conflicting) and uses terms like “inherited” and “member of” so I haven’t been able to get a clear answer.
Also, a side question of interest to me but not really necessary to know, I don’t see in ghc on GutHub the declaration for class Eq a
. I did find it in docs under Data.Eq and the uri indicates in is in the ‘base’ package but I don’t see a base package on github.