On Fri, 09 Jul 2010 16:26:13 -0700, Ivan Lazar Miljenovic 
<[email protected]> wrote:

"Kevin Quick" <[email protected]> writes:

I would think that only mutually recursive default methods would
require respecification and that there could be any number of default
methods that were reasonable as is.  Since it's probably quite
difficult for the Haskell compiler to analytically detect
non-terminating v.s. terminating mutual recursion it may be useful to
define an explicit comment flag for this case.

For example:

   class Show a where
      shows = showsPrec 5
      showsPrec _ = shows
      {-# REDEFINE_ONE: shows showsPrec #-}

This would fairly simply allow a warning to be generated for an
instance which did not redefine one of the identified methods; it
would capture that requirement in the same place the recursive
definition was defined, it would avoid false warnings, and it would be
backward compatible (and it might be Haddock-able as well).

This should be generalised IMO, since there might be cases where you
have to redefine either (foo && bar) || baz; of course, that makes the
syntax specification, etc. of the pragma more difficult...

I'm having trouble envisioning a restriction case such as you describe.  Can 
you provide an example?

The comment can't dictate that the resulting redefined method isn't still 
mutually recursive, but the warning for the lack of any override should provide 
enough of a trigger for the developer to read the docs/code and write an 
appropriate method.  If foo, bar, and baz are all interrelated it seems to me 
that an appropriate override of any of them could provide the necessary exit 
from recursion.

That's probably an interesting assertion that one of the category theorists 
around here could prove or disprove.  ;-)

--
-KQ
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to