[Haskell] Empty instance declaration

Isaac Dupree isaacdupree at charter.net
Fri Dec 28 12:33:29 EST 2007


Ralf Laemmel wrote:
>> You did not say anything that's imprecise about "mentioning each other
>> in a cycle", just the well-known fact that it's not equivalent to total
>> termination checking (in fact, it's neither fully an overestimate nor
>> underestimate of termination -- it's just an estimate that's likely to
>> be right when used in the context of default method definitions).
> 
> It's imprecise also in so far that you would need to define what you mean by it.
> Does it mean that we focus on the "pattern"
> 
> f ... = g ...
> g ... = f ...
> 
> ... or does it include the case
> 
> f ... = h g ...
> g ... = f ...

yes it does. It also probably includes
f ... = ...
   where _ignored1 = g
g ... = ...
   where _ignored2 = f

Predictability is a good thing, I think

although
class where
   f ... = g ...
   g ... = h ...

h ... = f ...

gets more complicated, but 'h' does have to be defined in the same 
module or module-cycle, because it refers to the class and the class 
refers to it

> 
> ... and that's still very imprecise because the dots don't mean anything proper.
> 
> Are you willing to look at the pattern *after* overloading resolution.

good point.  I think GHC can know when it refers to the same instance.

> 
> Let's have a proper termination checker!

I think GHC already does, in its strictness analyzer?  An incomplete 
checker of course, because termination checking of Haskell, like of most 
languages, is undecidable in general.

> 
> Btw, obviously a class by itself would not be checked (in terms of the
> default methods), but only an instance (with the defaults pulled in).

the class would at most be analyzed to see which were the minimal 
methods to implement -- it's warnings about instances that we've been 
talking about, anyway


Isaac


More information about the Haskell mailing list