, , , , .
data MyType x = A x | B x x deriving (Eq) , ,
instance Eq x => Eq (MyType x) where
A x1 == A x2 = x1 == x2
B x1 x2 == B x3 x4 = x1 == x3 && x2 == x4
_ == _ = False
, ( Eq x => ), - n 2 .
, " ", , - ; , , deriving (Eq) , , , - , , Eq , - .
, - . . , , , n :
newtype EverythingIsEqual x = E x deriving (Show)
instance Eq (EverythingIsEqual x) where
_ == _ = True
data MyType x = A (EverythingIsEqual x) | B x x deriving (Show, Eq, Ord)
newtype , Eq - - ; , " , , ", " " Haskell Ord, - , , . "