7
データタイプがPraat
です。 Praat
をEq
のインスタンスにして、mx
が等しい場合にのみ2つのPraat
が等しいとします。どのようにこれを行うのですか?タイプをイクのインスタンスにする方法
-- 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) = ...........
これはインスタンスを定義しようとしていますが、動作しません。
-- 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
私は 'mx'に'(==) 'と書いていました。 –