Avoiding No explicit method ... warnings
This isn't a bug, just a suggestion. It's not even a very important suggestion, but one that might be worth implementing if it's easy and you can find the the time. Or perhaps I am just doing things the wrong way? The point is that I sometimes have something like the following situation class ComplicatedClass x where simpleTitleFn :: x - String muchMoreComplicatedTitleFn :: extra arguments - x - IO (WithError (Source blah blah blah String) muchMoreComplicatedTitleFn _ x = [ ... some expression involving simpleTitleFn ...] The idea is that only muchMoreComplicatedTitleFn must always work; however instances may choose to implement it directly, or implement the much simpler function simpleTitleFn (if that does all they want). At the moment the situation is that someone who defines just muchMoreComplicatedTitleFn will get an unnecessary warning message from the compiler about No explicit method or default method for simpleTitleFn. I suggest instead introducing a new class of optional method (for example, via a pragma {-# OPTIONAL_METHOD simpleTitleFn #-}) which compiles exactly as normal except that (1) no warning is given for instances which don't define it; (2) a warning is given whenever anyone outside the class declaration *uses* simpleTitleFn. ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Avoiding No explicit method ... warnings
I think if you define a default method in the class definition you will not get this message - the default one can do nothing. Regards, Keean Schupke George Russell wrote: This isn't a bug, just a suggestion. It's not even a very important suggestion, but one that might be worth implementing if it's easy and you can find the the time. Or perhaps I am just doing things the wrong way? The point is that I sometimes have something like the following situation class ComplicatedClass x where simpleTitleFn :: x - String muchMoreComplicatedTitleFn :: extra arguments - x - IO (WithError (Source blah blah blah String) muchMoreComplicatedTitleFn _ x = [ ... some expression involving simpleTitleFn ...] The idea is that only muchMoreComplicatedTitleFn must always work; however instances may choose to implement it directly, or implement the much simpler function simpleTitleFn (if that does all they want). At the moment the situation is that someone who defines just muchMoreComplicatedTitleFn will get an unnecessary warning message from the compiler about No explicit method or default method for simpleTitleFn. I suggest instead introducing a new class of optional method (for example, via a pragma {-# OPTIONAL_METHOD simpleTitleFn #-}) which compiles exactly as normal except that (1) no warning is given for instances which don't define it; (2) a warning is given whenever anyone outside the class declaration *uses* simpleTitleFn. ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Avoiding No explicit method ... warnings
George Russell wrote: This isn't a bug, just a suggestion. It's not even a very important suggestion, but one that might be worth implementing if it's easy and you can find the the time. Or perhaps I am just doing things the wrong way? The point is that I sometimes have something like the following situation class ComplicatedClass x where simpleTitleFn :: x - String muchMoreComplicatedTitleFn :: extra arguments - x - IO (WithError (Source blah blah blah String) muchMoreComplicatedTitleFn _ x = [ ... some expression involving simpleTitleFn ...] The idea is that only muchMoreComplicatedTitleFn must always work; however instances may choose to implement it directly, or implement the much simpler function simpleTitleFn (if that does all they want). At the moment the situation is that someone who defines just muchMoreComplicatedTitleFn will get an unnecessary warning message from the compiler about No explicit method or default method for simpleTitleFn. I suggest instead introducing a new class of optional method (for example, via a pragma {-# OPTIONAL_METHOD simpleTitleFn #-}) which compiles exactly as normal except that (1) no warning is given for instances which don't define it; (2) a warning is given whenever anyone outside the class declaration *uses* simpleTitleFn. This seems to be a lot of mechanism for questionable benefit. A simpler and cleaner approach, IMHO, is the following: class ComplicatedClass x where complicatedTitleFn :: extra arguments - x - IO (WithError (Source blah blah blah String) makeComplicatedTitleFn :: (x - String) - extra arguments - x - IO (WithError (Source blah blah blah String) makeComplicatedTitleFn simpleTitleFn = [ ... some expression involving simpleTitleFn ...] Each instance either defines complicatedTitleFn directly, or uses makeComplicatedTitleFn with a simple title function: instance ComplicatedClass Foo where complicatedTitleFn = makeComplicatedTitleFn simpleFooTitleFn simpleFooTitleFn = ... Dean ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: Avoiding No explicit method ... warnings
| 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 given for instances which don't define it; (2) a warning is given 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 ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Avoiding No explicit method ... warnings
Simon Peyton-Jones wrote: [snip] 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 given for instances which don't define it; (2) a warning is given 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? [snip] Yes, this looks just as good as my original idea, if not better. Especially as it would be an easy change to make. In fact there are some cases where I might want to use simpleTitleFn on a Trust me, it's defined for this type basis, but that could be achieved by exporting an equivalent, but deprecated, function. ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
PROPS
WE HAVE FOR SALE: 1 500 PROPS GALAVANIZED SIZE 260-350, 500 sqm DOKA FRAMAX ALU and STEEL. PICTURES AND MORE INFO CAN WE PROVIDE YOU PER E-MAIL. BEST REGARDS. STABILO. ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users