Trying to create a base class from which I can derive different types. What's wrong with the following?
class (Eq a) => MyClass a
data Alpha = Alpha
instance MyClass Alpha where
Alpha == Alpha = True
I get the error:
test.hs:5:10: `==' is not a (visible) method of class `MyClass'
Failed, modules loaded: none.
You have to make Alpha an instance of Eq explicitly. This will work:
data Alpha = Alpha
instance Eq Alpha where
Alpha == Alpha = True
instance MyClass Alpha
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With