[Haskell-cafe] bug in ghci ?

Daniel Fischer daniel.is.fischer at web.de
Thu Jul 8 12:48:34 EDT 2010


On Thursday 08 July 2010 18:24:05, Ben Millwood wrote:
> On Thu, Jul 8, 2010 at 3:45 PM, Daniel Fischer <daniel.is.fischer at web.de> 
wrote:
> > Well, I made the suggestion of emitting a warning on instance
> > declarations without method definitions. That would be comparatively
> > easy to implement (even with an additional check to only emit the
> > warning if the class defines any methods) and catch many (if not most)
> > cases.
>
> Unfortunately, it would catch some perfectly valid cases, see the list
> of instances for flat datatypes here:
>
> http://hackage.haskell.org/packages/archive/deepseq/1.1.0.0/doc/html/src
>/Control-DeepSeq.html
>
> This demonstrates that there is at least one (admittedly probably not
> much more than one) case where a class with methods would have a
> default implementation that was total and valid in some cases.

Good point.
So one should check for more than one class-method [then defining no 
methods in the instance declaration is likely to lead to a default-method 
loop if there are default methods for all, otherwise GHC will warn 
already].
That can of course still give rise to spurious warnings, but is less likely 
to.


More information about the Haskell-Cafe mailing list