I declare my data type as an instance of class Num and implement only method sum (+). The other methods like (*), negate, abs, fromInteger, etc. I don’t implement. The reason is I don’t need these methods for my data type.
I compile the programme, and it’s ok except some uncomfortable warnings such as:
Warning: No explicit method nor default method for `*'
...
How can I avoid these warnings, or do I need to implement the above methods? Actually, I don’t want to implement them.
You can silence these warnings with a command line flag (in GHC)
But if you only want to implement addition, then it is probably not appropriate to make your type an instance of
Num. If you want just to have a nice operator for an operation on the type, you can define your own, you can even re-use(+)if you