Avoiding "No explicit method ..." warnings
Simon Peyton-Jones
simonpj@microsoft.com
Tue, 21 Jan 2003 15:08:09 -0000
| This seems to be a lot of mechanism for questionable benefit. A
simpler and cleaner
| approach, IMHO, is the following:
I rather agree.
One other idea though. Suppose you say
class ComplicatedClass x where
_simpleTitleFn :: x -> String
muchMoreComplicatedTitleFn :: extra arguments -> x -> IO ...
In general GHC doesn't report "warning unused" for variables whose name
begin with an underscore. In the case of class methods, I don't think
it suppresses the warning, but that would be an easy change to make.
Indeed, it would arguably be more consistent to do so anyway
> #-}) which compiles exactly as normal except that (1) no warning is=20
> given for instances which don't define it; (2) a warning is given=20
> whenever anyone outside the class declaration *uses* simpleTitleFn.
The "_" idea would achieve (1). You could get (2) by not exporting the
"_" method from the module defining ComplicatedClasss.
How would that be?
Simon