[Haskell-cafe] bug in ghci ?

Kevin Quick quick at sparq.org
Fri Jul 9 20:46:31 EDT 2010


On Fri, 09 Jul 2010 16:26:13 -0700, Ivan Lazar Miljenovic <ivan.miljenovic at gmail.com> wrote:

> "Kevin Quick" <quick at sparq.org> 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


More information about the Haskell-Cafe mailing list