How to make a type an instance of Eq

I have a data type called Praat . I want Praat be an instance of Eq , so two Praat are equal if and only if mx are equal. How to do it?

 -- data type data Praat t = Praat [k] [(k,k,k,k)] -- praat gives the maximum frequency Praat t -> Int mx (Praat [] _) = 0 mx (Praat (e:es) pt) = ........... 

This is how I try to determine the instance, but it does not work.

 -- I want to make Praat instance of Eq so that two Praat are equal -- when their respective `mx` are equal instance Eq Praat where mx :: (Praat k)->Int (mx k) == (mx k) = True _ == _ = False 
+7
source share
1 answer
 instance Eq Praat where x == y = mx x == mx y 

This is pretty much a direct translation of what you said. x is equal to y when mx x == mx y .

+14
source

All Articles