Eq deriving for universally quantified type - Haskell

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

Sridhar Ratnakumar

Is there an automated way to derive Eq for this type?

data Foo = forall r. Foo (Bar r, Baz r)
Sridhar Ratnakumar

Going manual for now:

data NeuronLink = forall r. NeuronLink (Query r, QueryConnection r, QueryViewTheme r)

instance Eq NeuronLink where
  (==) (NeuronLink (Query_ZettelByID zid1, c1, t1)) (NeuronLink (Query_ZettelByID zid2, c2, t2)) =
    and [zid1 == zid2, c1 == c2, t1 == t2]
  (==) (NeuronLink (Query_ZettelsByTag p1, c1, t1)) (NeuronLink (Query_ZettelsByTag p2, c2, t2)) =
    and [p1 == p2, c1 == c2, t1 == t2]
  (==) (NeuronLink (Query_Tags p1, c1, t1)) (NeuronLink (Query_Tags p2, c2, t2)) =
    and [p1 == p2, c1 == c2, t1 == t2]
  (==) _ _ =
    False
Sridhar Ratnakumar

I suspect GEq and deriveGEq can simplify that instance.

Sandy Maguire

generics can't yet represent existentials

Lysxia

kind-generics is the future of generics :)