Adding `Eq` instance to Generically
Suggestion to add Eq (Generically a)
.
Is it enough to derive via the underlying generic representation (geq
)? If that is the case the implementation is:
instance (Generic a, Eq (Rep a ())) => Eq (Generically a) where
(==) :: Generically a -> Generically a -> Bool
Generically a == Generically b = ((==) `on` from @a @()) a b
Without this instance we cannot implement Hashable (Generically a)
, because of the superclass relationship.
There is another generic implementation that I haven't looked into: Generics.Deriving.Eq
I originally suggested not including this instance to expedite the inclusion of Generically
because it can already be derived and in case there might be a discrepancy between deriving stock Eq
and deriving Eq via Generically T
.
If there is no discrepency we can add Ord
and Generic.Data.Internal.Traversable
.
instance (Generic a, Ord (Rep a ())) => Ord (Generically a) where
compare :: Generically a -> Generically a -> Ordering
compare (Generically a) (Generically b) = (compare `on` from @a @()) a b