I have a container type, called X
. Since I want heterogeneous lists over X
, its constructor is existentially typed over some type variable a
. However, I want it to be an instance of the Eq
type class. A hackish solution looks like this:
{-# LANGUAGE GADTs #-}
data X where X :: (Eq a, Show a) => a -> X
instance Eq X where
X x == X y = show x == show y
What would be the simplest (clean) solution for this problem?
(X
s don't equal if they don't have the same type.)